Yuav Siv Api Li Cas

Cov txheej txheem:

Yuav Siv Api Li Cas
Yuav Siv Api Li Cas

Video: Yuav Siv Api Li Cas

Video: Yuav Siv Api Li Cas
Video: peb yuav ua cas Youtube thiaj nce sai , yooj yim 2024, Kaum ib hlis
Anonim

Muaj tseeb txhua txhua programmer tau tuaj hla qhov API (daim ntawv thov lub ntsej muag sib xyaw) lossis cov ntawv thov lub ntsej muag. Ntawm nws qhov tseem ceeb, nws yog hom kev kawm tshwj xeeb, kev ua haujlwm, qhov tsis xwm yeem uas tau muab los ntawm daim ntawv thov, kev pabcuam, lossis cov haujlwm ua haujlwm. Siv los ntawm cov software tsim los sau ntau cov khoom software.

Yuav siv api li cas
Yuav siv api li cas

Cov Lus Qhia

Kauj ruam 1

Siv VKontakte social network API rau Flash ntawv. Txhawm rau siv kev sib sau ua ke ntawm lub xaib no, rub tawm cov ntawv hu ua APIConnection.zip los ntawm nplooj ntawv tsim tawm. Ntim cov ntawv rub tawm rau hauv daim nplaub tshev nrog qhov chaw ntawv ntawm daim ntawv thov uas yuav cuam tshuam nrog lub tsev qiv ntawv. Txhawm rau pib ua haujlwm nrog APIConnection, sib txuas chav kawm vk. APIConnection rau koj txoj haujlwm. Tsim qhov piv txwv ntawm chav kawm no. Lub npov flashVars tsuas yog qhov ntsuas me me rau nws cov kws tsim kho. Ntawm no yog ib qho piv txwv ntawm kev pib ua ib daim ntawv thov:

var flashVar: Nruas = theem.loaderInfo.parameters li kwv;

var VK: APIConnection = tshiab APIConnection (flashVar);

Kauj ruam 2

Siv ntawm Google maps API. Cov interface no yog siv los tso duab qhia rau ntawm koj nplooj ntawv. Txhawm rau pib, txais tus yuam sij ntawm https://code.google.com/intl/ru/apis/maps/signup.htm. Txuas ntxiv siv nws hauv koj nplooj:

Yog tias koj xav sim siv daim duab qhia ntawm localhost, koj tuaj yeem tso tus {koj yuam sij} parameter seem. Txuas daim pheem thib API. Txhawm rau ua qhov no, nkag mus rau cov chaws li qhia saum toj no. Tom qab ntawv, muab tshuaj txhuam rau hauv qhov chaws html code:

Thov nco ntsoov - qhov thaiv nrog tus id daim duab sab hauv yuav muaj cov ntaub ntawv hauv daim ntawv qhia. Txhawm rau pom daim duab qhia chaw, muab lo rau JavaScript code:

ua haujlwm initialize () {// Qhov haujlwm no yuav raug hu thaum nplooj ntawv tau thauj khoom.

yog tias (GBrowserIsCompatible ()) {// Kuaj xyuas yog tias qhov browser ua tau raws li cov duab ntawv

var daim ntawv qhia = tshiab GMap2 (cov ntaub ntawv.getElementById ("daim ntawv qhia")); // Tsim cov piv txwv ntawm cov chav kawm daim ntawv qhia, qhov twg daim duab yog tus id ntawm qhov thaiv uas los ua kom pom daim duab qhia chaw.

map.setCenter (tshiab GLatLng (62.424198, 25.962219), 15); // Muab cov kev sib koom ua ke ntawm daim duab qhia. 15 yog tus nplai ntawm daim duab qhia.

}

}

Nco ntsoov them sai sai rau kev tshaj tawm ntawm qhov ua haujlwm ntawm thaj chaw ntawm thaj chaw uas daim duab qhia chaw.

Pom zoo: