gpt4 book ai didi

jquery - Instagram 关注者计数 - 使用 jQuery/json 和 PHP

转载 作者:行者123 更新时间:2023-12-01 04:49:25 25 4
gpt4 key购买 nike

经过几个小时的工作和 Sahil Mittal 的一点帮助,我们成功地使用 jQuery/json 和 PHP 检索了 Instagram 关注者计数。这是我们设法整理的内容,希望对其他想要获取 Instagram 信息的人有所帮助。

我们的 jQuery:

// INSTAGRAM COUNT WITH HOVER
$('.instagram a').hover(
function () {
var instaurl = 'getdata.php'; // Add your PHP URL here.
$.getJSON(instaurl, function(data){
var instacount = data["data"]["counts"]["followed_by"];
$('.instagram a').html(instacount);
});
},
function () {
$('.instagram a').html('Instagram');
});

我们的 PHP (getdata.php):

   header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
$instaurl = file_get_contents("https://api.instagram.com/v1/users/XXXXXXX/?access_token=XXXXXXXXXXXXXXXXXXXX"); // Add your ID & Access Token
echo $instaurl;

最佳答案

只要去掉奇怪的括号

var insta_count = data.data.counts.followed_by;
$('li.instagram a').html(insta_count);

关于jquery - Instagram 关注者计数 - 使用 jQuery/json 和 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23090178/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com