php 如何使用他们的 API 显示 Instagram 个人资料图片
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18945434/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to display Instagram Profile Picture with their API
提问by Billy Rammal
I've been trying and researching this for a while now, to no avail.
我已经尝试并研究了一段时间,但无济于事。
All I want is a simple method (without using someone else's messy API) to request a user's profile picture. I have the authentication and everything setup, I just don't understand how to call other information.
我想要的只是一个简单的方法(不使用其他人的凌乱 API)来请求用户的个人资料图片。我有身份验证和一切设置,我只是不明白如何调用其他信息。
The documentation is confusing to me, first time using an API: http://instagram.com/developer/endpoints/users/#get_users
第一次使用 API 时,文档让我感到困惑:http: //instagram.com/developer/endpoints/users/#get_users
Any ideas?
有任何想法吗?
回答by krisrak
Here is the simplest way to get profile picture using instagram API with javascript/jquery.
这是使用带有 javascript/jquery 的 instagram API 获取个人资料图片的最简单方法。
Replace ACCESS_TOKEN with you access token and set USER_ID to the instagram user id you want profile picture.
将 ACCESS_TOKEN 替换为您的访问令牌,并将 USER_ID 设置为您想要的个人资料图片的 instagram 用户 ID。
<html>
<head>
<title>Instagram</title>
<script src="http://codeorigin.jquery.com/jquery-2.0.3.min.js"></script>
<script type="text/javascript">
var access_token = "ACCESS_TOKEN";
var user_id = "USER_ID";
var url = "https://api.instagram.com/v1/users/"+user_id+"?access_token="+access_token+"&callback=?";
$.getJSON(url, function(data) {
$("body").append("<img src='"+data.data.profile_picture+"' />");
});
</script>
</head>
<body>
</body>
</html>

