我嘗試使用Windows Azure Marketplace API執行必應搜索,我下載了他們的指南和示例代碼。該代碼準備與基本身份驗證的HTTPS請求,但我不斷收到以下錯誤:用於Windows搜索引擎的Bing搜索的Windows Azure身份驗證
Warning: file_get_contents(https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Web?Query=%27washburn%27&Adult=%27Off%27&$top=50&$format=Atom): failed to open stream: Connection refused
PHP代碼(從微軟的文檔):
$context = stream_context_create(array(
'http' => array(
'proxy' => 'tcp://127.0.0.1:8888',
'request_fulluri' => true,
'header' => "Authorization: Basic " . base64_encode($accountKey.":".$accountKey)
)
));
有誰知道是什麼原因造成請錯誤?我已經正確設置了$accountKey
,並在瀏覽器中對其進行了測試。我有點困惑的是127.0.0.1:8888
也base64_encode($accountKey.":".$accountKey)
,你怎麼需要$accountKey
之前和之後:
而在使用瀏覽器時,你應該留下用戶名爲空,只需輸入帳戶密碼到密碼字段?
您可以爲第一個$ accountKey使用其他內容,因爲無論如何它都將被忽略。 –