topfile_get_contents

file_get_contents  时间:2021-05-19  阅读:()
MigratingBingSearchAPIApplicationsIntroductionTheBingSearchAPIenablesdevelopersandinformationworkstoembedandcustomizesearchresultsinapplicationsorwebsitesbyusingXMLorJavaScriptObjectNotation(JSON).
Youcanaddsearchfunctionalitytoawebsite,createuniqueconsumerorenterpriseapplications,ordevelopnewmash-ups.
TheBingSearchAPIgivesyouaccesstoweb,image,news,andvideoresults,aswellasrelatedsearchandspellingsuggestions.
TheBingSearchAPI2.
0istransitioningtoanofferingthat'savailableinWindowsAzureMarketplaceviasubscription.
WindowsAzureMarketplaceisacloud-baseddataservicethatenablesdevelopersandinformationworkerstofind,acquire,andconsumepublisheddatasetsandwebservices.
Userssubscribetodatasetsandwebservicesofinterestandcanintegratetheinformationintotheirownapplicationsviastandardizeddataservices.
TheycananalyzethedataonlinebyusingtheServiceExplorertoolorbyusingagrowingbodyoftoolslikePowerPivotinMicrosoftExcel.
ThenewversionoftheBingSearchAPIincludes:Meteredsubscriptionofquerylimits.
HTTPSqueryURLs(sometimescalled"endpoints")thatprovideresultsineitherXMLorJSONmediaformats.
OpenDataProtocol(OData)supportforeasyconsumptionacrossmultipledevelopmentsystems.
Improvedsupportfordatatypes.
TheabilitytomonetizeapplicationsintheWindowsAzureMarketplace.
Accesstofresherresultsandimprovedrelevance.
ThemovetoWindowsAzureMarketplacewillrequireeachcustomertofollowamigrationprocess.
Thisguidedescribesthemigrationprocessandgivesusagesamples.
MigratingtotheBingSearchAPIinWindowsAzureMarketplaceTomigrateyourexistingapplicationfromBingAPI2.
0totheBingSearchAPIinWindowsAzureMarketplace,completethestepsinthissection.
YoucanexpectmigratingtothenewBingSearchAPItoinvolvethefollowingchangesinyourexistingapplication:TargetingofanewqueryURLModeratechangestotherequestandresponseschemasSecurityrequirementtoauthenticateaccesstoyourdatasubscription1.
SubscribetoaBingSearchAPIofferingSelectoneofthefollowingofferings.
ProductofferingCapabilitiesBingSearchAPIProvidesaccesstoBingweb,image,video,news,andrelatedsearchresults,aswellasspellingsuggestionsBingSearchAPI-WebResultsOnlyProvidesaccesstoBingwebresultsonlyAfteryouselectanoffering,chooseanoffervariantthatrepresentsthenumberofqueriesyouwanttosubscribeto.
BingSearchAPIcomesinmanyvariantstomeetyourtrafficdemand,includingafreetime-limitedtrialforprototyping.
SelecttheoffervariantbyclickingtheTRYFREEorBUYbutton.
Afteryouselecttheoffervariant,you'llbeaskedtoprovidebillinginformation,includingacreditcardnumber.
Fortrialoffers,thecreditcardwillbeusedtoconverttheofferintoapaidsubscriptionafterthetrialperiodends.
Ifyoudon'twanttoconverttoapaidoffer,youcancancelyoursubscriptionbeforethetrialperiodends.
WindowsAzureMarketplacewillbillthespecifiedamounttoyourcreditcardeachmonth,foraslongasthesubscriptionisactive.
YoucanviewyouractivesubscriptionsontheMyDatapageinWindowsAzureMarketplace.
2.
ChangeyourqueryURLChangeyourBingSearchAPIqueryURLfromthecurrentlyconfiguredBingSearchAPI2.
0queryURL(thatis,http://api.
bing.
net)tooneofthefollowing,dependingonwhichproductofferingyou'vesubscribedto.
ProductofferingQueryURLBingSearchAPIhttps://api.
datamarket.
azure.
com/Bing/Search/BingSearchAPI-WebResultsOnlyhttps://api.
datamarket.
azure.
com/Bing/SearchWeb/TheServiceExplorertoolinWindowsAzureMarketplacecanhelpyouexperimentwiththenewBingSearchAPIandgeneratequeryURLs.
YoucanaccessServiceExplorerbyusingoneofthefollowinglinks,dependingonwhichproductofferingyou'vesubscribedto.
ProductofferingServiceExplorerlinkBingSearchAPIhttps://datamarket.
azure.
com/dataset/explore/5BA839F1-12CE-4CCE-BF57-A49D98D29A44BingSearchAPI-WebResultsOnlyhttps://datamarket.
azure.
com/dataset/explore/8818F55E-2FE5-4CE3-A617-0B8BA8419F65ThefollowingillustrationisanexampleofdevelopingandrunningaqueryinServiceExplorer.
ThequeryURLisexpressedviatheODataspecification.
ThedifferencesbetweenthisspecificationandBingSearchAPI2.
0areasfollows:BecausestringparameterswillbeusedtogenerateaURL,theymustbeURLencoded.
Soinsteadofbeingenclosedinapostrophes('),thestringparametersaresurroundedbytheASCIIequivalent%27.
Forinstance:https://api.
datamarket.
azure.
com/Bing/Search/WebQuery=%27Xbox%27Note:Ifthequerytextmightcontainnon-alphanumericcharacters,youshouldURLencodetheentirestring.
ThenamesofthecountandoffsetparametershavebeenchangedtocomplywiththeODatastandard.
Furthermore,insteadofhavingadifferentqueryURLforeachresponsetype(JSONversusXML),aspecialODataparameterisused.
ThefollowingtableliststheODataparameters.
ReservedparameterDescriptionEquivalentinBingSearchAPI2.
0DefaultvalueExample$topSpecifiesthenumberofresultstoreturn.
&count=50(50isthemaximum)https://api.
datamarket.
azure.
com/Bing/Search/WebQuery=%27Xbox%27&$top=10$skipSpecifiestheoffsetrequestedforthestartingpointofresultsreturned.
&offset=0https://api.
datamarket.
azure.
com/Bing/Search/WebQuery=%27Xbox%27&$top=10&$skip=20$formatSpecifiestheformatoftheODataresponse.
CurrentoptionsareAtom(forXML)orJSON.
AlternativeformatswereaccomplishedwithdifferentqueryURLs(forexample,xml.
aspxandjson.
aspx)Atomhttps://api.
datamarket.
azure.
com/Bing/Search/WebQuery='Xbox'&$top=10&$skip=20&$format=ATOMFormoreinformationaboutOData,visittheODatawebsite.
Note:TheODatareservedparametersdonotrequirethattheircorrespondingvaluesbeURLencodedandenclosedinapostrophes('),theASCIIequivalent%27.
BingAPIDataMarketsupportsHTTPcompressiontosaveontransferdatavolumeanddelivery.
ToenableHTTPcompression,addheader"Accept-Encoding:gzip"toyourHTTPrequest.
3.
AppendtheserviceoperationtotheendofthequeryURLAserviceoperationisthedatasourcethatistargetedforBingSearchAPIresults.
BingSearchAPI2.
0referencedthisasthe&Source=parameter.
Forinstance,ifthetargeteddatasourceis"web,"appendtheserviceoperationWebtotheendofyourqueryURLasfollows:https://api.
datamarket.
azure.
com/Bing/Search/WebTheserviceoperationsavailableintheBingSearchAPIDataMarketarelistedinthefollowingtable.
ServiceOperationEquivalentinBingSearchAPI2.
0ExampleWebWebhttps://api.
datamarket.
azure.
com/Data.
ashx/Bing/Search/Web$top=10ImageImagehttps://api.
datamarket.
azure.
com/Data.
ashx/Bing/Search/Web$top=10VideoVideohttps://api.
datamarket.
azure.
com/Data.
ashx/Bing/Search/Web$top=10NewsNewshttps://api.
datamarket.
azure.
com/Data.
ashx/Bing/Search/Web$top=10SpellingSuggestionSpellhttps://api.
datamarket.
azure.
com/Data.
ashx/Bing/Search/Web$top=10RelatedSearchRelatedSearchhttps://api.
datamarket.
azure.
com/Data.
ashx/Bing/Search/Web$top=10Compositehttps://api.
datamarket.
azure.
com/Data.
ashx/Bing/Search/CompositeSources=%27web%2bnews%27&Query=%27XBox%27&$top=1Note:Torequestmultipledatasourcesinasinglequery,specifytheserviceoperationnamed"Composite"followedbyitsrequiredparameternamed"Sources".
Thevalueappliedto"Sources"arethenameoftheserviceoperationsconcatenatedwitha+character.
Seethetableaboveforanexampleofasinglequeryrequestingweb&news.
AlsonotethatthenumberofresultsreturnedwiththeODatareservedparameter$toprefertoalldatasourcesspecifiedinthequeryexceptNews.
Newswillalwaysreturnafixednumberof15newsresultswhenusedinaquerywithaCompositeserviceoperation.
4.
SpecifyrequiredandoptionalparametersSpecifytherequiredandoptionalparametersbyappendingparameterizedname/valuepairstothequeryURL,asincommonREST-likeinterfaces.
TheparametersaredocumentedinatableundertheDetailstaboftheofferingthatyou'vesubscribedto.
Forinstance,ifyou'rebuildingaquerywiththerequiredparameterqueryofvalue'XBOX'andtheoptionalparametermarketofvalue'en-GB',appendtheparameterizedname/valuepairstotheendofyourqueryURLasfollows:https://api.
datamarket.
azure.
com/Bing/SearchWeb/WebQuery=%27Xbox%27&Market=%27en-GB%275.
ObtainyouraccountkeyToauthenticateaBingSearchAPIrequestwithWindowsAzureMarketplace,youmustobtainanaccountkey.
ThismodeofauthenticationreplacestheAppIDusedintheBingSearchAPI2.
0.
Youcanobtainyouraccountkeybyusingeitherofthefollowingmethods:GototheAccountKeyspageandaddanewaccountkeyforyourapplication.
Thisistherecommendedmethodbecauseyoucanremovethisaccountkeyifitbecomescompromised.
GototheAccountKeyspageandusethedefaultaccountkey.
6.
InsertthequeryURLintoabrowserToissueyourrequestfortheBingSearchAPI,insertthequeryURLbuiltfromthepreviousstepsintoabrowser.
WindowsAzureMarketplacesupportsBasicAuthenticationtoauthenticaterequeststoyourdatasubscription.
You'llbepromptedforausernameandpasswordfromyourbrowser.
Leavetheuser-namefieldemptyandenteryouraccountkeyinthepasswordfield.
ThebrowserwilldisplayXMLresultsreturnedfromtheBingSearchAPI.
7.
AdjustyourresponseparsinglogicAdjustyourresponseparsinglogictomatchtheupdatedresponseformat.
ThefollowingsectionscomparequeryresponsesbetweenBingSearchAPI2.
0andtheBingSearchAPIthat'savailableinWindowsAzureMarketplace.
ResultscontainerSomechangesweremadetotheelementsthatcontaintheresultsarray.
ThisincludestheSearchResponseelement,theSearchResponse/Queryelement,andtheimmediatechildrenofthesource-type-specificcontainerslikeweb:Webandmms:Image.
Version2.
0WindowsAzureMarketplaceRequestshttp://api.
search.
live.
net/xml.
aspxAppid=App&query=odata&sources=web&count=2https://api.
datamarket.
azure.
com/Bing/Search/WebQuery=%27odata%27&$top=2ResponseTreesSearchResponseFeed-Query-SearchTerms-link-web:Web-entry-web:Total-web:Offset-web:Results-contentNote:Otherpropertiesomittedforclarity.
Removeddata:SearchTerms.
Becausethisissentacrossthewireintherequest,itisnotnecessaryintheresponse.
Ifsomeasynchronousprogrammingpatternrequiresthattheresponsebeverified,theidresponsepropertycanbeusedtoobtainthefullrequestURL.
Total.
Iftherearenomorepagesofresults,the/feed/link[@rel='next']propertywillnolongerappear,andthetotalisnolongerneededforenablingpaging.
Offset.
ThisvalueisusedtohelpdevelopersbuildtherequestURLforthenextpageofresults.
IntheODataprotocol,thenextpageofresultsisrequestedviathehrefpropertyof/feed/link[@rel='next'].
ThenextpageofresultscanbeobtainedsimplybyrequestingthisURL.
WebresultsVersion2.
0WindowsAzureMarketplaceRequestshttp://api.
search.
live.
net/xml.
aspxAppid=App&query=odata&sources=web&count=2https://api.
datamarket.
azure.
com/Bing/Search/WebQuery=%27odata%27&$top=2ResponseTreesSearchResponseFeed-web:Web-web:Results-web:WebResult-entry-content-m:properties-d:ID-web:Title-d:Title-web:Description-d:Description-web:DisplayURL-d:DisplayUrl-web:URL-d:Url-web:CacheUrl-web:DateTime-web:DeepLinks-web:SearchTagsNote:Otherpropertiesomittedforclarity.
Removeddata:CacheUrl.
Deprecated.
DateTime.
Deprecated.
DeepLinks.
Deprecated.
SearchTags.
Deprecated.
Addeddata:ID.
Aresultset/uniqueIDforthisrow.
Renameddata:URL.
ThispropertywasrenamedtoUrl.
DisplayURL.
ThispropertywasrenamedtoDisplayUrl.
ImageresultsVersion2.
0WindowsAzureMarketplaceRequestshttp://api.
search.
live.
net/xml.
aspxAppid=App&query=odata&sources=image&count=2https://api.
datamarket.
azure.
com/Bing/Search/ImageQuery=%27odata%27&$top=2ResponseTreesSearchResponseFeed-mms:Image-mms:Results-mms:ImageResult-entry-content-m:properties-d:ID-mms:Title-d:Title-mms:MediaUrl-d:MediaUrl-mms:Url-d:SourceUrl-mms:DisplayUrl-d:DisplayUrl-mms:Width-d:Width-mms:Height-d:Height-mms:FileSize-d:FileSize-mms:ContentType-d:ContentType-mms:Thumbnail-d:Thumbnail-mms:Url-d:MediaUrl-mms:ContentType-d:ContentType-mms:Width-d:Width-mms:Height-d:Height-mms:FileSize-d:FileSizeNote:Otherpropertiesomittedforclarity.
Addeddata:ID.
Aresultset/uniqueIDforthisrow.
Renameddata:URL.
ThispropertywasrenamedtoSourceUrl.
VideoresultsVersion2.
0WindowsAzureMarketplaceRequestshttp://api.
search.
live.
net/xml.
aspxAppid=App&query=odata&sources=image&count=2https://api.
datamarket.
azure.
com/Bing/Search/ImageQuery=%27odata%27&$top=2ResponseTreesSearchResponseFeed-mms:Image-mms:Results-mms:VideoResult-entry-content-m:properties-d:ID-mms:Title-d:Title-mms:PlayUrl-d:MediaUrl-mms:SourceTitle-mms:RunTime-d:RunTime-mms:ClickThroughPageUrl-d:DisplayUrl-mms:StaticThumbnail-d:Thumbnail-mms:Url-d:MediaUrl-mms:ContentType-d:ContentType-mms:Width-d:Width-mms:Height-d:Height-mms:FileSize-d:FileSizeNote:Otherpropertiesomittedforclarity.
Removeddata:SourceTitle.
Deprecated.
Addeddata:ID.
Aresultset/uniqueIDforthisrow.
Renameddata:PlayUrl.
ThispropertywasrenamedtoMediaUrl.
ClickThroughPageUrl.
ThispropertywasrenamedtoDisplayUrl.
StaticThumbnail.
ThispropertywasrenamedtoThumbnail.
StaticThumbnail/Url.
ThispropertywasrenamedtoMediaUrl.
NewsresultsVersion2.
0WindowsAzureMarketplaceRequestshttp://api.
search.
live.
net/xml.
aspxAppid=App&query=odata&sources=news&count=2https://api.
datamarket.
azure.
com/Bing/Search/NewsQuery=%27odata%27&$top=2ResponseTreesSearchResponseFeed-news:News-news:Results-news:NewsResult-entry-content-m:properties-d:ID-news:Title-d:Title-news:Url-d:Url-news:Source-d:Source-news:Snippet-d:Description-news:Date-d:Date-news:BreakingNewsNote:Otherpropertiesomittedforclarity.
Removeddata:BreakingNews.
Deprecated.
Addeddata:ID.
Aresultset/uniqueIDforthisrow.
Renameddata:Snippet.
ThispropertywasrenamedtoDescription.
RelatedsearchresultsVersion2.
0WindowsAzureMarketplaceRequestshttp://api.
search.
live.
net/xml.
aspxAppid=App&query=odata&sources=RelatedSearch&count=2https://api.
datamarket.
azure.
com/Bing/Search/RelatedSearchQuery=%27odata%27&$top=2ResponseTreesSearchResponseFeed-rs:RelatedSearch-rs:Results-rs:RelatedSearchResult-entry-content-m:properties-d:ID-rs:Title-d:Title-rs:Url-d:BingUrlNote:Otherpropertiesomittedforclarity.
Addeddata:ID.
Aresultset/uniqueIDforthisrow.
SpellingsuggestionresultsVersion2.
0WindowsAzureMarketplaceRequestshttp://api.
search.
live.
net/xml.
aspxAppid=App&query=odata&sources=spell&count=2https://api.
datamarket.
azure.
com/Bing/Search/SpellingSuggestionsQuery=%27odata%27&$top=2ResponseTreesSearchResponseFeed-spl:Spell-spl:Results-spl:SpellResult-entry-content-m:properties-d:ID-spl:Value-d:ValueNote:Otherpropertiesomittedforclarity.
Addeddata:ID.
Aresultset/uniqueIDforthisrow.
UsagesamplesThissectionshowsusagesamplesinavarietyoflanguagestohelpdevelopersstartusingthenewBingSearchAPI.
UsingtheAPIwiththeMicrosoft.
NETFrameworkviaC#ThemoststraightforwardapproachtousingtheAPIwithC#istodownloadaserviceproxyfromtheBingAPIlandingpageinWindowsAzureMarketplace.
Afteryousubscribetotheoffer,you'llseeabuttonlikethisonedirectlybelowtheoffervariantslist:Ifyouclickthisbutton,youcandownloadtheproxytoyourcomputer.
Next,youcanmovethislibraryintoyourprojectdirectoryandaddittoyourproject.
Togetstartedwiththeproxy,seethefirsttwosectionsofWalkthrough:MicrosoftTranslatorinaC#ConsoleApplication.
Aftertheproxyhasbeenaddedtoyourproject,youcanstartcodingagainstitalmostimmediately.
Thefollowingsampleconsoleapplicationsynchronouslyperformsanimagesearchanddownloadsthesearchresults.
Important:BesuretoaddareferencetoSystem.
Data.
Services.
Clientbeforeyoubuildyourproject.
usingSystem;usingSystem.
Net;namespaceImageSearchConsole{classProgram{staticvoidMain(string[]args)varbingContainer=newBing.
BingSearchContainer(newUri("https://api.
datamarket.
azure.
com/Bing/Search/"));replacethisvaluewithyouraccountkeyvaraccountKey="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";thenextlineconfiguresthebingContainertouseyourcredentials.
bingContainer.
Credentials=newNetworkCredential(accountKey,accountKey);nowwecanbuildthequeryvarimageQuery=bingContainer.
Image("xbox",null,null,null,null,null);varimageResults=imageQuery.
Execute();foreach(varresultinimageResults)Console.
WriteLine(result.
Title);Console.
ReadLine();}}UsingtheAPIwiththeMicrosoft.
NETFrameworkviaVisualBasicBecauseofthepopularityofworkingwithXMLcontentinVisualBasic,thefollowingsamplehasbeentailoredtoconsumetherawAtomresponsefromtheBingSearchAPIdirectlyinVisualBasic.
NET.
ThesampleaimstoexecuteasimpleimagequeryagainsttheBingSearchAPIandtoprintsomeattributeofeachimageresponsetotheconsole.
Tousethissample,createanewVisualBasicconsoleapplicationandpastethesamplecodeintothemain.
vbfile.
ImportsSystem.
XmlImportsSystem.
NetModuleModule1SubMain()ReplacethisvaluewithyouraccountkeyDimaccountKeyAsString="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="TheWindowsAzureMarketplaceServiceRootUrlfortheBingSearchofferDimserviceRootAsString="https://api.
datamarket.
azure.
com/Bing/Search/"TheQuerytypewe'reperformingDimimageQueryRootAsString=serviceRoot+"Image"TheQuerystring,surroundedbyUrlEncodedquotesDimimageQueryAsString=imageQueryRoot+"Query=%27xbox%27"AnXmlDocumentwewillusetoreadtheresultsDimdocumentAsXmlDocument=NewXmlDocument()ThenextfourlinesconfiguretheXmlDocumenttouseyourcredentialswhenqueryingtheImageSearchAPIDimaccountCredentialAsNewNetworkCredential(accountKey,accountKey)DimresolverAsNewXmlUrlResolver()resolver.
Credentials=accountCredentialdocument.
XmlResolver=resolverWithcredentialsconfiguredwedownloadthequeryresultsdocument.
Load(imageQuery)ThisnamespacemanagerwillassistwithparsingtheresultsDimnamespaceManagerAsXmlNamespaceManager=NewXmlNamespaceManager(document.
NameTable)namespaceManager.
AddNamespace("atom","http://www.
w3.
org/2005/Atom")namespaceManager.
AddNamespace("m","http://schemas.
microsoft.
com/ado/2007/08/dataservices/metadata")namespaceManager.
AddNamespace("d","http://schemas.
microsoft.
com/ado/2007/08/dataservices")Thisquerygetsthe"Next"linkfortheresultset.
document.
Loadthisvaluetogetthenextsetofresults.
IfthevalueisNothingthentherearenomoreresults.
DimnextResultSetAsString=document.
SelectSingleNode("/atom:feed/atom:link[@rel='next']/@href",namespaceManager).
ValueThisgetsthepropertiesnodeforeachImagesearchresultDimimageResultsAsXmlNodeList=document.
SelectNodes("/atom:feed/atom:entry/atom:content/m:properties",namespaceManager)ForEachimageResultAsXmlNodeInimageResultsSelecttheTitleelementfromthisimageResultDimtitleAsString=imageResult.
SelectSingleNode(".
//d:Title",namespaceManager).
InnerTextConsole.
WriteLine(title)NextEndSubEndModuleUsingtheAPIwithSilverlightSilverlightisaMicrosoftframeworkthatenablesdeveloperstobuildRichInternetApplications(RIAs)byusingmanyofthesame.
NETFrameworklibrariesandprogramminglanguagesthatthey'reaccustomedtousinginclassic.
NETapplications.
Becauseofitsstrongintegrationwithbrowsersaswellaswithimagesandothermedia,it'sausefulclientforbuildingapplicationsviatheBingSearchAPI.
LikeJSONapplicationsthatresideinthebrowser,Silverlightapplicationscan'ttypicallyinvokeservices(rawHTTPorSOAP)ondomainsotherthanthedomainfromwhichtheSilverlightapplicationisdownloaded.
ButbecauseWindowsAzureMarketplacepublishesacross-domainpolicyfileattherootofitsdomain(https://api.
datamarket.
azure.
com/crossdomain.
xml)thatallowsRIAplatformslikeSilverlighttoaccessitsqueryURLs,it'spossibletousetheAPIfromSilverlight.
BecauseSilverlightisreallya.
NETprogrammingenvironment,thechoicesforAPIinvocationarethesameastheearlier.
NETsamples(althoughSilverlightalsohasaJSON-parsingobjectmodel).
Youcanusethesameproxyclassthatyousawintheearlier.
NETsamples.
Tohelpdevelopersbuildveryresponsiveapplications,however,SilverlightrequiresthatWebrequestsareperformedasynchronouslyratherthansynchronously.
ThefollowingsampleshowsaSilverlightapplicationobtainingdatafromtheBingImageSearchservice.
ItassumesthatyouhavealreadyaddedtheBingproxytoyourapplication,aswasshownintheC#sample.
usingSystem;usingSystem.
Data.
Services.
Client;usingSystem.
Linq;usingSystem.
Net;usingSystem.
Windows;usingSystem.
Windows.
Controls;namespaceBingApp{publicpartialclassMainPage:UserControl{publicMainPage()InitializeComponent();privatevoidbutton1_Click(objectsender,RoutedEventArgse)varbingContainer=newBing.
BingSearchContainer(newUri("https://api.
datamarket.
azure.
com/Bing/Search/"));replacethisvaluewithyouraccountkeyvaraccountKey="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";thenexttwolinesconfigurethebingContainertouseyourcredentials.
bingContainer.
Credentials=newNetworkCredential(accountKey,accountKey);note,thislinewasnotrequiredfortheC#consoleappbingContainer.
UseDefaultCredentials=false;thenexttwolinesdefinetherequestfordataandvarimageQuery=bingContainer.
Image("xbox",null,null,null,null,null);imageQuery.
BeginExecute(newAsyncCallback(this.
ImageResultLoadedCallback),imageQuery);privatevoidImageResultLoadedCallback(IAsyncResultar)varimageQuery=(DataServiceQuery)ar.
AsyncState;varenumerableImages=imageQuery.
EndExecute(ar);varimagesList=enumerableImages.
ToList();hereyoucouldalsochoosetosimplybindtheresultslisttoacontrolinyourUI.
Instead,wewillsimplyiterateovertheresults.
foreach(varimageinimagesList)dosomethingwiththeimage,orbindtheimage}}UsingtheAPIwithPHPPHPhasapowerfulJSONparsingmechanism.
BecausePHPisadynamiclanguage,theparsingmechanismenablesPHPdeveloperstoprogramagainstaJSONobjectgraphinastraightforwardway.
ThefollowingsampleshowsaPHPpagethatsendsarequesttotheJSONinterfacebyusingthefile_get_contentsfunctiontocalltheJSONqueryURL,andthejson_decodefunctiontoturntheresultsintoanobjectgraphthatcanbewalkedandturnedintoHTML.
PHPBing">Typeinasearch:"/>array('request_fulluri'=>true,'header'=>"Authorization:Basic".
base64_encode($accountKeyaccountKey))));$request=$WebSearchURL.
urlencode(POST["searchText"echo($request);$response=file_get_contents($request,0,$context);$jsonobj=json_decode($response);echo('');foreach($jsonobj->d->resultsas$value){echo('MediaURL.
'">');echo('Thumbnail->MediaUrl.
'">');}echo("");}>UsingtheAPIwithotherdevelopmentenvironmentsWindowsAzureMarketplaceexposestheBingSearchAPIbyusingthewell-knownandbroadlysupportedODataprotocol.
Inadditiontoprovidingacommonlanguagewithwhichtoexposedata,ODataprovidesBingSearchAPIcustomerswithabroadsetoftoolsandlibrariesthattheycanusetoconsumeODataservicesliketheBingSearchAPIinavarietyofprogramminglanguages.
TolearnmoreaboutthelibrarysupportavailableforOData,seetheODataSDK.
Ofcourse,youcanalsousetheBingSearchAPItofindwebresultsforthequery"odatasdk".
TobrowsetheBingSearchAPIODataservices,youcanquerytheODatametadata,whichreturnsacompletedescriptionofhowtheservicecanbecalled,whatparametersitexpects,andwhatdatastructuresitreturns.
Itthusservesaroughlysimilarpurposeasamethodsignatureinaprogramminglanguage.
ToaccesstheODatametadata,appendtheODatakeyword$metadatatotheendofthequeryURLofthedatasubscriptionoftheBingSearchAPIofferingthatyouselected,asshowninthefollowingtable.
ProductofferingQueryURLBingSearchAPIhttps://api.
datamarket.
azure.
com/Bing/Search/$metadataBingSearchAPI-WebResultsOnlyhttps://api.
datamarket.
azure.
com/Bing/SearchWeb/$metadata

ZJI:韩国BGP+CN2线路服务器,国内三网访问速度优秀,8折优惠码每月实付440元起

zji怎么样?zji最近新上韩国BGP+CN2线路服务器,国内三网访问速度优秀,适用8折优惠码zji,优惠后韩国服务器最低每月440元起。zji主机支持安装Linux或者Windows操作系统,会员中心集成电源管理功能,8折优惠码为终身折扣,续费同价,全场适用。ZJI是原Wordpress圈知名主机商:维翔主机,成立于2011年,2018年9月启用新域名ZJI,提供中国香港、台湾、日本、美国独立服...

VirMach:$7.2/年KVM-美元512MB/$7.2/年MB多个机房个机房可选_双线服务器租赁

Virmach对资源限制比较严格,建议查看TOS,自己做好限制,优点是稳定。 vCPU 内存 空间 流量 带宽 IPv4 价格 购买 1 512MB 15GB SSD 500GB 1Gbps 1 $7/VirMach:$7/年/512MB内存/15GB SSD空间/500GB流量/1Gbps端口/KVM/洛杉矶/西雅图/芝加哥/纽约等 发布于 5个月前 (01-05) VirMach,美国老牌、稳...

Sharktech$129/月,1Gbps不限流量,E5-2678v3(24核48线程)

Sharktech最近洛杉矶和丹佛低价配置大部分都无货了,只有荷兰机房还有少量库存,商家又提供了两款洛杉矶特价独立服务器,价格不错,CPU/内存/硬盘都是高配,1-10Gbps带宽不限流量最低129美元/月起。鲨鱼机房(Sharktech)我们也叫它SK机房,是一家成立于2003年的老牌国外主机商,提供的产品包括独立服务器租用、VPS主机等,自营机房在美国洛杉矶、丹佛、芝加哥和荷兰阿姆斯特丹等,主...

file_get_contents为你推荐
OPENCORE苹果引导配置说明第四版-基于支持ipad支持ipad国家标准苹果5地址163Deviceios5columnios5canvas2Canvas ~セピア色のモチーフ~ 这个动画片的中文翻译是什么?从哪看?win7如何关闭445端口如何判断445端口是否关闭联通iphone4iphone4想换联通的卡 是普通联通的卡都能开通3G么 还是得换联通3G卡 联通都有什么套餐 我是北京的
免费国际域名 阿里云搜索 电信测速器 国外服务器 英文简历模板word vip购优汇 gspeed 工作站服务器 域名转接 爱奇艺vip免费试用7天 paypal注册教程 流媒体加速 中国电信宽带测速器 上海电信测速网站 web应用服务器 东莞服务器托管 游戏服务器出租 免费asp空间申请 阿里云手机官网 登陆qq空间 更多