开发者

Fetching google contact data using AuthSub

Can anyone there please point me where did i go wrong with this?

<?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 />';
        }
    }
}

?>

And this is the link i m using to redirect user to google -

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

It keeps giving me this -

HTTP/1.1 400 Bad Request 

Content-Type: text/html; charset=UTF-8 Date: Sun, 28 Nov 2010 09:59:53 GMT Expires: Sun, 28 Nov 2010 09:59:53 GMT Cache-Control: private, max-age=0 X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block Server: GSE Transfer-Encoding: chunked

Invalid request URI

Any idea anyone? I know i m wrong in one or more places, but my brain is not working, as i m trying with this for almost 4 hours :D

Thanks, Anjan


Sorry my mistake :)

I found out that i have to use

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

instead of

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

Thanks, Anjan

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜