【问题标题】:Google Web Master Tools - API and PHP PUTGoogle Web Master Tools - API 和 PHP PUT
【发布时间】:2011-02-11 21:50:50
【问题描述】:

我正在尝试在 PHP 中使用 Google Webmaster Tools API :) 我已经设法在我的帐户中创建用于创建网站的功能.. 但现在我正试图让验证工作......

这是文档: 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/

但是我尝试过的一切都不起作用......例如......

$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);

任何人有一些想法如何使验证工作? :)

【问题讨论】:

    标签: php google-search-console


    【解决方案1】:
    $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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-15
      • 1970-01-01
      • 1970-01-01
      • 2013-12-06
      • 1970-01-01
      • 2021-12-29
      相关资源
      最近更新 更多