Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
来自facebook api的未定义响应数据?_Facebook_Api - Fatal编程技术网

来自facebook api的未定义响应数据?

来自facebook api的未定义响应数据?,facebook,api,Facebook,Api,我从facebook上获得专辑名,并用下面的代码将它们写在页面上。 问题是它也包含了未定义的内容,所以它会写两张“墙上的照片”,那么我如何防止它写出未定义的内容呢 FB.api('/xxxxxxxxxxxxxxx/albums', function(response) { if (response && response.data && response.data.length){ var ul = document.getElementById('

我从facebook上获得专辑名,并用下面的代码将它们写在页面上。 问题是它也包含了未定义的内容,所以它会写两张“墙上的照片”,那么我如何防止它写出未定义的内容呢

FB.api('/xxxxxxxxxxxxxxx/albums', function(response) {

  if (response && response.data && response.data.length){
    var ul = document.getElementById('fb-albumslist');
    for (var i=0, l=response.data.length; i<l; i++) {
     if (response.data !== "undefined"){    
      var
        album = response.data[i],
        li = document.createElement('li'),
        a = document.createElement('a');
      a.innerHTML = album.name;
      a.href = album.link;
      li.appendChild(a);
      ul.appendChild(li);
    }
   }
  }
  });
我正在尝试“if(response.data!==”undefined“{”,但我不知道怎么做?
感谢您的任何意见!

Facebook似乎正在创建另一个具有以下属性的墙照相册:

{
  "id": "YYYY",
  "from": {
    "name": "AAAA",
    "id": "XXX"
  },
  "name": "Wall Photos",
  "privacy": "custom",
  "type": "friends_walls",
  "created_time": "2011-02-02T08:54:20+0000",
  "updated_time": "2011-02-02T08:54:20+0000",
  "can_upload": false
}, 
我不确定这张专辑的目的,但最好的办法是检查
链接是否存在,否则跳过:

if(!album.link) continue;

您好,谢谢,但我无法让它工作,如果我使用您的代码,我会得到以下错误:TypeError:“undefined”不是一个对象(评估'album.link'),我不确定该怎么办?我将它替换为“if(response.data!=“undefined”){只需将它放在这一行之前:
a.innerHTML=album.name;
if(!album.link) continue;