예전 Bing API에서 새 API로 응용 프로그램을 포팅했습니다. 새로운 PHP가 어떻게 작동하는지에 대한 여러 게시물을 보았습니다. 인증 문제가 발생했습니다.새로운 Bing API PHP에서 지원되지 않는 인증
$accountKey = $this->Appid;
$ServiceRootURL = "https://api.datamarket.azure.com/Bing/Search/";
$WebSearchURL = $ServiceRootURL . 'Image?$format=json&Query=';
$context = stream_context_create(array(
'http' => array(
'request_fulluri' => true,
'header' => "Authorization: Basic " . base64_encode($accountKey . ":" . $accountKey)
)
));
$request = $WebSearchURL . urlencode('\'' . $_POST["searchText"] . '\'');
echo($request);
$this->response = file_get_contents($request, 0, $context);
$this->results = json_decode($this->response);
이 시도 이후 :
Warning: file_get_contents(https://api.datamarket.azure.com/Bing/Search/Image?$format=json&Query=%27%27) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 401 The authorization type you provided is not supported. Only Basic and OAuth are supported in /home/krem81/public_html/classes/class.BingSearch.php on line 178
차례로
이 내가 API와 상호 작용하는 데 사용하고있는 기능은 다음과 같습니다이
는 URL에 의해 반환되는 오류입니다 나는 또한 지금 시도했다$accountKey = $this->Appid;
$ServiceRootURL = "https://api.datamarket.azure.com/Bing/Search/";
$WebSearchURL = $ServiceRootURL . 'Image?$format=json&Query=';
$request = $WebSearchURL . urlencode('\'' . $this->keyword . '\'');
echo($request);
$process = curl_init($request);
curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($process, CURLOPT_USERPWD, $accountKey . ":" . $accountKey);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
$this->response = curl_exec($process);
var_dump($this->response);
$this->results = json_decode($this->response);
var_dump($this->results);
누군가는 au를 방아쇠를 당길 수 있던 무슨과에 관해서 아이디어가 있는가? 실패 할 증언?
가능한 [Bing 검색 API 및 Azure] (http://stackoverflow.com/questions/10844463/bing-search-api-and-azure) – ManseUK
불행히도 그 스레드 도움이되지 않았고, 모든 솔루션을 시도했지만 어느 누구도 나를 잡아 내지 못했습니다. –
키가 실제로 있는지 확인하기 위해 헤더를 확인 했습니까? – ManseUK