使用javascript SDK从facebook graph api获取个人资料图片

时间:2018-06-10 14:32:28

标签: javascript facebook-graph-api

当我尝试使用facebook graph api获取facebook个人资料图片时,它显示未定义的response.data。 这里是获取个人资料照片的代码

  FB.api('/me/picture?width=180&height=180', function (response) {
                        console.log(response);
                     document.getElementById('status').innerHTML = "<img src=" +response.data.url+ ">";
    });

html将是

<div id="status"></div>

这是我的图表浏览器图片

enter image description here

我做错了,请任何人指导我......

提前致谢

当我控制响应对象时

它显示如下

error: {…}
​​
code: 1
​​
error_subcode: 1357046
​​
message: "Received Invalid JSON reply."
​​
type: "http"

1 个答案:

答案 0 :(得分:0)

请使用以下代码重试:

Curl -H "X-Goog-Api-Key: PUT_YOUR_API_KEY_HERE" \
  -H "Content-Type: application/json; charset=utf-8" \
  --data "{
    'input':{
      'text':'Android is a mobile operating system developed by Google,
         based on the Linux kernel and designed primarily for
         touchscreen mobile devices such as smartphones and tablets.'
    },
    'voice':{
      'languageCode':'en-gb',
      'name':'en-GB-Standard-A',
      'ssmlGender':'FEMALE'
    },
    'audioConfig':{
      'audioEncoding':'MP3'
    }
  }" "https://texttospeech.googleapis.com/v1beta1/text:synthesize" > synthesize-text.txt