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

knownhost西雅图/亚特兰大/阿姆斯特丹$5/月,2个IP1G内存/1核/20gSSD/1T流量

美国知名管理型主机公司,2006年运作至今,虚拟主机、VPS、云服务器、独立服务器等业务全部采用“managed”,也就是人工参与度高,很多事情都可以人工帮你处理,不过一直以来价格也贵。也不知道knownhost什么时候开始运作无管理型业务的,估计是为了扩展市场吧,反正是出来较长时间了。闲来无事,那就给大家介绍下“unmanaged VPS”,也就是无管理型VPS,低至5美元/月,基于KVM虚拟,...

恒创科技SonderCloud,美国VPS综合性能测评报告,美国洛杉矶机房,CN2+BGP优质线路,2核4G内存10Mbps带宽,适用于稳定建站业务需求

最近主机参考拿到了一台恒创科技的美国VPS云服务器测试机器,那具体恒创科技美国云服务器性能到底怎么样呢?主机参考进行了一番VPS测评,大家可以参考一下,总体来说还是非常不错的,是值得购买的。非常适用于稳定建站业务需求。恒创科技服务器怎么样?恒创科技服务器好不好?henghost怎么样?henghost值不值得购买?SonderCloud服务器好不好?恒创科技henghost值不值得购买?恒创科技是...

vdsina:俄罗斯VPS(datapro),6卢布/天,1G内存/1核(AMD EPYC 7742)/5gNVMe/10T流量

今天获得消息,vdsina上了AMD EPYC系列的VDS,性价比比较高,站长弄了一个,盲猜CPU是AMD EPYC 7B12(经过咨询,详细CPU型号是“EPYC 7742”)。vdsina,俄罗斯公司,2014年开始运作至今,在售卖多类型VPS和独立服务器,可供选择的有俄罗斯莫斯科datapro和荷兰Serverius数据中心。付款比较麻烦:信用卡、webmoney、比特币,不支持PayPal...

file_get_contents为你推荐
甘肃省武威市人民检察院技术检验鉴定Dimensionfastreport2I:\Sam-research\QEF\Publications\Conferencepresent37支持ipad支持ipad支持ipad支持ipad图书馆学、情报学期刊投稿指南重庆网通中国联通重庆分公司的公司简介
budgetvm 老鹰主机 10t等于多少g 42u机柜尺寸 云主机51web 个人空间申请 云全民 qq云端 空间技术网 免费cdn 100mbps 路由跟踪 万网主机 免备案jsp空间 wordpress空间 SmartAXMT800 linuxvi命令 赵荣博客 qq部落18-3 电脑主机 更多