php – “你的授权标题在这里”,那是什么?
我已经实施了Google API v3.0,但文档总是告诉您将“您的授权标题放在此处”.
我们应该作为授权标题传递的值是多少? 但他们从未提及过这个价值的来源. curl_setopt($ressource,CURLOPT_HTTPHEADER,array( "GData-Version: 3.0","Authorization: Bearer " . http_build_query(json_decode($_SESSION['access_token'])) )); 我收到以下错误:
经过大量搜索,我试图在“OAuth”前加上: curl_setopt($ressource,"Authorization: OAuth " . http_build_query(json_decode($_SESSION['access_token'])) )); 它也不会工作,但至少错误似乎更冗长:
所以,他们为什么要谈论AuthSub,AFAIK(我觉得我不太了解),我使用的是OAuth 2.0,而不是AuthSub. 再次搜索该错误会导致可能的范围问题(http://www.geoffmcqueen.com/2010/03/14/token-invalid-authsub-token-has-wrong-scope-oauth-google-problem/). 所以我仔细检查我的范围. 'services' => array( /* ... */,'documentList' => array('scope' => 'https://docs.google.com/feeds/') ) 请注意,我自己添加了documentList范围. 我的代码: $this->authenticate(); $arrAuth = json_decode($_SESSION['access_token']); $authenticationHeader = "Bearer " . $arrAuth->access_token $url = "https://docs.google.com" . "/feeds/default/private/full"; $atomContent = <<<ATOM <?xml version='1.0' encoding='UTF-8'?> <entry xmlns="http://www.w3.org/2005/Atom"> <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/docs/2007#folder"/> <title>Example Collection</title> </entry> ATOM; $ressource = curl_init(); curl_setopt($ressource,CURLOPT_URL,$url); curl_setopt($ressource,array( "GData-Version: 3.0","Authorization: {$authenticationHeader}" )); curl_setopt($ressource,CURLOPT_TIMEOUT,5); curl_setopt($ressource,CURLOPT_POST,1); curl_setopt($ressource,CURLOPT_POSTFIELDS,$atomContent); $httpResponse = curl_exec($ressource); 如果这个问题对某些人来说不明显: 感谢您的投入……我现在已经挣扎了一段时间…… 解决方法
我相信
http://code.google.com/apis/storage/docs/authentication.html就是你要找的:)
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |