在Facebook Graph Api中返回未定义的图像字段

时间:2018-03-15 10:20:14

标签: javascript facebook-graph-api facebook-javascript-sdk

我试图通过回调函数返回字段图像并将其传递到元素wall-post但是它未定义。我想知道是否有一个涉及可以定义字段的url标记的函数?

    window.fbAsyncInit = function() {
    FB.init({
      appId            : '*********',
      autoLogAppEvents : true,
      xfbml            : true,
      version          : 'v2.12'


    });
        FB.api('https://graph.facebook.com/page_name/posts/?access_token=****************', {fields: 'message,link,created_time,name,story, images'}, function(response) 
            {
                for (var l = response.data.length, i = 0; i < l; i++) {
                    var obj = response.data[i];



                        var node = document.createElement("wall-post");  
                        //var node2 = document.createElement("wall-post-header");  
                            var textNode = document.createTextNode(obj.images);
                            //var timeNode = document.createTextNode(obj.created_time);
                                node.appendChild(textNode);
                                //node2.appendChild(timeNode);
                                node.style=' display: inline-block;margin: 15px;margin-top: 30px; border-radius: px;overflow-y: hidden;box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);float:left;';
                                //node2.style='height: 50px;overflow: hidden;background-color:#272727;color: white;line-height: 31px;padding: 9px;float: right;text-align: right;display: inline-block;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;font-size: 12px; line-height: 31px;padding: 9px;float: left;text-align: left;display: inline-block;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;width: 70%';
                            document.body.appendChild(node);
                            //document.body.appendChild(node2);

                        }
                    })
                };

  (function(d, s, id){
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(s); js.id = id;
     js.src = "https://connect.facebook.net/en_US/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk')
);

0 个答案:

没有答案