2011-02-11 92 views
1

我想在PHP中使用谷歌網站管理員工具API: 我已經設法在我的帳戶中創建網站的功能..但現在我試圖讓驗證工作...谷歌網站管理員工具 - API和PHP PUT

這裏是老學究: http://code.google.com/intl/hr-HR/apis/webmastertools/docs/2.0/developers_guide_protocol.html#AD_Verifying

所以,問題是......在文檔說: 然後提交認證PUT請求: https://www.google.com/webmasters/tools/feeds/sites/http%3A%2F%2Fwww%2Eexample%2Ecom%2F/

但一切我都試過不工作k ...例如..

$method = strtoupper('put'); 
$opts = array('http' => 
    array(
     'method' => $method, 
     'protocol_version' => 1.0, 
     'header' => 'Content-type: application/atom+xml'."\n Authorization: GoogleLogin auth=".$auth."\n Content-Length: ".strlen($content), 
     'content' => $content 
    ) 
); 
$context = stream_context_create($opts); 
$result = file_get_contents($url, false, $context); 

任何人有一些想法如何使驗證工作? :)

回答

2
$method = strtoupper($method); 
$opts = array('http' => 
    array(
     'method' => $method, 
     'protocol_version' => 1.0, 
     'header' => 'Content-type: ' . $contentType . 
        (isset($this->auth) && isset($this->auth['Auth']) ? "\nAuthorization: GoogleLogin auth=" . $this->auth['Auth'] : '') . 
        "\nContent-Length: " . strlen($content), 
     'content' => $content 
    ) 
); 
$context = stream_context_create($opts); 
**$result = @file_get_contents($url, false, $context);** 
return $result; 
相關問題