首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Google Web Master Tools - API和PHP PUT

Google Web Master Tools - API和PHP PUT
EN

Stack Overflow用户
提问于 2011-02-12 05:50:51
回答 1查看 647关注 0票数 1

我正在尝试在PHP中使用Google网站管理员工具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/

但我试过的所有东西都不管用。例如..

代码语言:javascript
复制
$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);

有没有人知道如何让验证工作?:)

EN

回答 1

Stack Overflow用户

发布于 2011-12-27 16:40:27

代码语言:javascript
复制
$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;
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4974445

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档