【发布时间】:2020-02-10 22:04:19
【问题描述】:
我正在尝试获取带有字幕的 instagram 个人资料帖子,除字幕外一切正常。 它显示:[object Object]
我没有使用任何 API。
我的代码:
function nFormatter(num){
if(num >= 1000000000){
return (num/1000000000).toFixed(1).replace(/\.0$/,'') + 'G';
}
if(num >= 1000000){
return (num/1000000).toFixed(1).replace(/\.0$/,'') + 'M';
}
if(num >= 1000){
return (num/1000).toFixed(1).replace(/\.0$/,'') + 'K';
}
return num;
}
$.ajax({
url:"https://www.instagram.com/bhudiptaakash?__a=1",
type:'get',
success:function(response){
$(".profile-pic").attr('src',response.graphql.user.profile_pic_url);
posts = response.graphql.user.edge_owner_to_timeline_media.edges;
posts_html = '';
for(var i=0;i<posts.length;i++){
caption = posts[i].node.edge_media_to_caption;
likes = posts[i].node.edge_liked_by.count;
posts_html += '<a href="https://instagram.com/p/'+shortcode+'">: '+caption+';
}
$(".posts").html(posts_html);
}
});
我该如何解决这个问题??
【问题讨论】:
-
标题是一个对象,你需要提取你想要的属性。
-
@Barmar 你能解决吗?
-
使用
console.log(caption),您应该会看到所有属性。 -
你有
edge_media_to_caption文档的链接吗?我在 Instagram Graph API 文档中找不到它。 -
什么都没发生
标签: javascript jquery instagram instagram-api instagram-graph-api