有没有人知道如何在不使用访问令牌的情况下获取Instagram用户的照片。看到{user}的照片在http://instagram.com/上,但无法使用Instagram API获取它们,这并没有意义。
谢谢
有没有人知道如何在不使用访问令牌的情况下获取Instagram用户的照片。看到{user}的照片在http://instagram.com/上,但无法使用Instagram API获取它们,这并没有意义。
谢谢
要获取照片,您不需要使用访问令牌。只需调用:
https://api.instagram.com/v1/users/{user-id}/media/recent?callback=&client_id={client_id}
你可以在这里创建你的client_id:
您根本不需要使用access_token
。只需在Instagram上注册您的应用程序,获取client_id
并使用它进行查询。
引用文档:
请注意,在许多情况下,您可能根本不需要对用户进行身份验证。例如,您可以在不进行身份验证的情况下请求热门照片(即,您无需提供access_token; 只需使用您的客户端ID进行请求)。我们仅在您的应用程序代表用户进行请求时(评论、点赞、浏览用户的Feed等)要求身份验证。
获取数据有两种方式
1)客户端 - 您需要提供客户端ID
2)服务器端 - 您需要提供访问令牌
https://api.instagram.com/v1/users/#{instagram_id}/media/recent/?access_token=#{@token}"
这将为您提供给定Instagram ID的用户最近上传的照片...
你好,这里有一个获取用户图像的示例,请按照以下代码操作:
/* Get image in your instagram Account */
$set_scope_your_app ="https://www.instagram.com/oauth/authorize/?
client_id=Added-your-client_id&
redirect_uri=Added-your-redirect_uri&response_typ
e=code&scope=public_content";
$get_acess_token = "https://instagram.com/oauth/authorize/?
client_id=Added-your-client_id&
redirect_uri=Added-your-redirect_uri&respons
e_type=token";
$url="https://api.instagram.com/v1/users/self/media/recent/?access_token=Added-your-access_token";
$json = file_get_contents($url);
$data = json_decode($json);
$images = array();
foreach( $data->data as $user_data ) {
$images[] = (array) $user_data->images;
}
$standard = array_map( function( $item ) {
return $item['standard_resolution']->url;
}, $images );
echo "<pre>";
print_r($standard);
echo "<pre>";
print_r($standard);
我从在Instagram中获取用户媒体或图像的示例中获得了参考。
client_id
即可。 - dayuloli