【问题标题】:Fetching google contact data using AuthSub使用 AuthSub 获取谷歌联系人数据
【发布时间】:2011-05-16 19:54:20
【问题描述】:

有人能指出我在哪里做错了吗?

<?php
if(!empty($_GET))
{
    if(isset($_GET['token']))
    {
        $token = $_GET['token'];

        $ch = curl_init('https://www.google.com/m8/feeds/');

        if($ch)
        {
            curl_setopt
            (
                $ch,
                CURLOPT_HTTPHEADER,
                array
                (
                /*  "Content-Type: application/x-www-form-urlencoded",*/
                    "Authorization: AuthSub token=\"{$token}\""
                )
            );
            curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
            //curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
            curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
            curl_setopt($ch,CURLOPT_HTTPGET,true);
            curl_setopt($ch,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);
            curl_setopt($ch,CURLOPT_HEADER,true);
            //curl_setopt($ch,CURLOPT_POST,true);

            $res = curl_exec($ch);

            echo $res.'<br />';
        }
    }
}

?>

这是我用来将用户重定向到谷歌的链接-

https://www.google.com/accounts/AuthSubRequest?scope=https://www.google.com/m8/feeds/&session=0&secure=0&next=http://www.etfaq.com/invite_friends.php%3Ftype%3Dgmail

它一直给我这个 -

HTTP/1.1 400 Bad Request 

内容类型:文本/html; 字符集=UTF-8 日期:2010 年 11 月 28 日星期日 09:59:53 GMT 过期:星期日,2010 年 11 月 28 日 09:59:53 GMT 缓存控制:私有,max-age=0 X-Content-Type-Options: nosniff X 框架选项:SAMEORIGIN X-XSS-防护:1; 模式=块服务器:GSE 传输编码:分块

请求 URI 无效

有人知道吗?我知道我在一个或多个地方错了,但我的大脑无法正常工作,因为我尝试了将近 4 个小时:D

谢谢, 安詹

【问题讨论】:

    标签: oauth google-api google-contacts-api authsub


    【解决方案1】:

    对不起我的错误:)

    我发现我必须使用

    curl_init('https://www.google.com/m8/feeds/default/full');

    而不是

    curl_init('https://www.google.com/m8/feeds/');

    谢谢, 安詹

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-14
      • 1970-01-01
      • 1970-01-01
      • 2020-10-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多