Instagram Follower Count - 使用jQuery / json& PHP [英] Instagram Follower Count - Using jQuery / json & PHP
本文介绍了Instagram Follower Count - 使用jQuery / json& PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
经过几个小时的工作和Sahil Mittal的一些帮助,我们设法使用jQuery / json和PHP来检索Instagram Follower Count。这是我们设法组合起来的,希望这可以帮助任何人寻求获取Instagram信息。
After a couple hours work and a little help from Sahil Mittal we've managed to retrieve the Instagram Follower Count using jQuery / json and PHP. This is what we've managed to put together and hope this helps anyone else looking to get Instagram information.
我们的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):
Our 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);
这篇关于Instagram Follower Count - 使用jQuery / json& PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文