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

Letbox(35美元/年),美国洛杉矶VPS终身7折

Letbox 云服务商在前面的文章中其实也有多次介绍,这个服务商其实也算是比较老牌的海外服务商,几年前我也一直有使用过他们家的VPS主机,早年那时候低至年付15-35美元左右的VPS算式比较稀缺的。后来由于服务商确实比较多,而且也没有太多的网站需要用到,所以就没有续费,最近这个服务商好像有点活动就躁动的发布希望引起他人注意。这不有看到所谓的家中有喜事,应该是团队中有生宝宝了,所以也有借此来发布一些...

iON Cloud:七月活动,洛杉矶CN2 GIA线路85折优惠中,价格偏高/机器稳定/更新优惠码

iON Cloud怎么样?iON Cloud是Krypt旗下的云服务器品牌,成立于2019年,是美国老牌机房(1998~)krypt旗下的VPS云服务器品牌,主打国外VPS云服务器业务,均采用KVM架构,整体性能配置较高,云服务器产品质量靠谱,在线率高,国内直连线路,适合建站等用途,支付宝、微信付款购买。支持Windows server 2012、2016、2019中英文版本以及主流Linux发行...

青果网络-618阿里云,腾讯云特惠优惠折上折!

官方网站:点击访问青果云官方网站活动方案:—————————–活动规则—————————1、选购活动产品并下单(先不要支付)2、联系我司在线客服修改价格或领取赠送时间3、确认价格已按活动政策修改正确后,支付订单,到此产品开设成功4、本活动产品可以升级,升级所需费用按产品原价计算若发生退款,按资源实际使用情况折算为产品原价再退还剩余余额! 美国洛杉矶CN2_GIACPU内存系统盘流量宽带i...

file_get_contents为你推荐
设备itunes建筑业127exportingjava国家标准苹果5css3圆角用CSS3怎么实现圆角边框?ipadwifiIPAD连上了WIFI,但是无法上网,急!!联通版iphone4s怎么区分iphone4s电信版和联通版重庆电信宽带测速重庆电信光纤宽带网络,内外网络和电脑等设备都没发生变化的情况下,办理了从20M提速到100M业务。chromeframeicharts 怎么支持ie8css选择器CSS中的选择器分几种?
linuxapache虚拟主机 ftp空间 国外在线代理 云全民 京东商城0元抢购 北京双线机房 怎样建立邮箱 腾讯实名认证中心 爱奇艺vip免费试用7天 息壤代理 外贸空间 国外免费云空间 rewritecond 新疆服务器 移动王卡 美国vpn代理 德国代理 tko 大硬盘分区 冰盾ddos防火墙 更多