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

Digital-VM80美元新加坡和日本独立服务器

Digital-VM商家的暑期活动促销,这个商家提供有多个数据中心独立服务器、VPS主机产品。最低配置月付80美元,支持带宽、流量和IP的自定义配置。Digital-VM,是2019年新成立的商家,主要从事日本东京、新加坡、美国洛杉矶、荷兰阿姆斯特丹、西班牙马德里、挪威奥斯陆、丹麦哥本哈根数据中心的KVM架构VPS产品销售,分为大硬盘型(1Gbps带宽端口、分配较大的硬盘)和大带宽型(10Gbps...

台湾云服务器整理推荐UCloud/易探云!

台湾云服务器去哪里买?国内有没有哪里的台湾云服务器这块做的比较好的?有很多用户想用台湾云服务器,那么判断哪家台湾云服务器好,不是按照最便宜或最贵的选择,而是根据您的实际使用目的选择服务器,只有最适合您的才是最好的。总体而言,台湾云服务器的稳定性确实要好于大陆。今天,云服务器网(yuntue.com)小编来介绍一下台湾云服务器哪里买和一年需要多少钱!一、UCloud台湾云服务器UCloud上市云商,...

PacificRack(19.9美元/年)内存1Gbps带vps1GB洛杉矶QN机房,七月特价优惠

pacificrack怎么样?pacificrack商家发布了七月最新优惠VPS云服务器计划方案,推出新款优惠便宜VPS云服务器采用的是国产魔方管理系统,也就是PR-M系列,全系基于KVM虚拟架构,这次支持Windows server 2003、2008R2、2012R2、2016、2019、Windows 7、Windows 10以及Linux等操作系统,最低配置为1核心2G内存1Gbps带宽1...

file_get_contents为你推荐
经济开发区127技术参数及要求:思科ipadnetbios端口如何组织netbios端口的外部通信google中国地图求教谷歌中国地图~手机如何使用?google中国地图怎样用GOOLE搜中国地图用卫星看的那一种(可以看到城市和房子的)联通iphone4联通iphone4跟苹果的iphone4有什么不一样? 比如少了什么功能? 还是什么的?电信版iphone4s4和苹果iPhone 4S 电信版有什么区别电信版iphone4s电信版iphone4s是买16gb的好还是32gb的好?ipad无法加入网络为什么ipad无法加入网络?
抗投诉vps主机 GGC 香港机房 流媒体服务器 域名优惠码 2017年黑色星期五 彩虹ip html空间 e蜗 169邮箱 天翼云盘 华为云建站 lamp的音标 徐州电信 成都主机托管 asp空间 web服务器 tko koss耳机 最好的空间日志 更多