【问题标题】:Issues accessing Facebook profile image访问 Facebook 个人资料图片的问题
【发布时间】:2015-12-04 18:45:30
【问题描述】:

我确信这种问题有一个简单的答案,但我已经用了好几天没有找到它。

当我尝试通过图形 API 访问 picture 时出现问题。

根据图形 API,以下 URL 应返回带有 is_silhouetteurl 的 JSON

https://graph.facebook.com/xxx/picture

当我在Graph Explorer 中尝试时,它工作正常,但是当我在浏览器中测试相同的 URL 时,我会自动重定向到响应的 URL 属性,而不是获取 JSON。

我的问题是我需要访问该 JSON 的内容以获取 URL 属性才能显示用户配置文件。

我的代码看起来像这样

var fbimage = "https://graph.facebook.com/" + e.uid + "/picture/";
    var xhrFbImage = Ti.Network.createHTTPClient({
        onload : function() {
            jsonData = '';
            jsonData = this.responseText;
            Ti.API.info("inside FB response...");
            Ti.API.info(jsonData);
        }
    });
    xhrFbImage.open("GET", getFbImage);
    xhrFbImage.send(); 

回复总是null

任何正确方向的提示将不胜感激。

【问题讨论】:

    标签: javascript json facebook titanium


    【解决方案1】:

    找到答案了。

    通过添加?redirect=false,我得到了没有重定向的实际 JSON。

    所以要查询的正确网址是

    https://graph.facebook.com/xxx/picture?redirect=false
    

    答案比我想象的更明显。可以参考这里

    https://developers.facebook.com/docs/graph-api/reference/user/picture/

    【讨论】:

      猜你喜欢
      • 2020-10-04
      • 1970-01-01
      • 2018-09-05
      • 2011-04-16
      • 2013-11-24
      • 2018-03-19
      • 1970-01-01
      • 2012-09-18
      • 1970-01-01
      相关资源
      最近更新 更多