检索/更改个人资料图片Google个人资料API

时间:2013-01-11 22:53:21

标签: google-profiles-api

我可以使用以下代码通过JQuery中的AJAX调用来检索配置文件信息:

var url = 'https://www.google.com/m8/feeds/profiles/domain/{DOMAIN_NAME}/full';
        $.ajax({
            url: url
                +'?access_token='
                +accessToken,
            headers: {
                'GData-Version': '3.0',
                'If-Match': '*'
            },
            async: false,
            dataType: 'text',
            success: function(data) {
                $('#result').text(data);
            }
        });
    };

但是,当我尝试检索具有相同访问令牌的图片时:

var url = 'https://www.google.com/m8/feeds/profiles/domain/{MY_DOMAIN}/full/{USER_NAME}';   
        $.ajax({
            url: url
                +'?access_token='
                +accessToken,
            headers: {
                'GData-Version': '3.0'
            },
            async: false,
            dataType: 'text',
            success: function(data) {
                $('#result').text(data);
            }
        });

我收到错误: 401(令牌无效 - AuthSub令牌的范围错误)

我使用的范围是配置文件数据api页面上提供的范围: https://www.google.com/m8/feeds/profiles

如何获得正确的授权?提供的访问令牌不能完成这项工作吗?

2 个答案:

答案 0 :(得分:0)

对于个人资料图片,我认为表单的网址应为

https://www.google.com/m8/feeds/photos/profile/domainName/userName

以下是文档: https://developers.google.com/google-apps/profiles/#retrieving_photo

你会尝试一下,看看它是否有效?

答案 1 :(得分:0)

尝试将此路径用作范围

https://www.google.com/m8/feeds/

您可以参考此post

相关问题