【问题标题】:Facebook Graph api profile picture URLFacebook Graph api 个人资料图片 URL
【发布时间】:2015-11-02 03:32:23
【问题描述】:

我正在尝试显示已登录用户的个人资料图片,但由于某种原因,网址已更改。这是我整理的函数

function testAPI() {
    FB.api('/me','GET',{"fields":"picture{url},name"},function(response) {
        var url = response.picture.data.url;
        console.log(url);
        $("#status").html('<p>'+response.name+'</p><figure id="profilePicture"><img href="'+response.picture.data.url+'"/></figure>');
        console.log(document.getElementById('status').innerHTML);
    });
}

第一个控制台日志返回:

https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpf1/v/t1.0-1/p50x50/12036592_10153768750487873_8195289030629933305_n.jpg?oh=5488c4b312a1b077b68243a7998d217e&oe=56BA5DE5&gda=1454718467_89331767e8555ed196c5559340774fbb

第二个返回正确的内部 html,因为用户名显示,但它添加了 amp;在网址中的 & 符号之后,因此不显示个人资料图片。不知道如何解决这个问题。任何帮助都会非常感谢。

【问题讨论】:

    标签: facebook-graph-api url sdk profile-picture


    【解决方案1】:

    您的&lt;img/&gt; 标记语法不正确,您应该使用src 而不是href

    变化:

    $("#status").html('<p>'+response.name+'</p><figure id="profilePicture"><img href="'+response.picture.data.url+'"/></figure>');
    

    收件人:

    $("#status").html('<p>'+response.name+'</p><figure id="profilePicture"><img src="'+response.picture.data.url+'"/></figure>');
    

    【讨论】:

      猜你喜欢
      • 2012-01-16
      • 2014-06-24
      • 2018-03-19
      • 2016-05-22
      • 1970-01-01
      • 2017-02-24
      • 2011-04-16
      • 1970-01-01
      相关资源
      最近更新 更多