Instagramm API PHP关注用户 [英] Instagramm API PHP Follow User
问题描述
当下,我尝试在网站中使用Instagramm API.哪个可以获取访问令牌,然后关注用户.
at the Moment i try to implent the Instagramm API in a Website. Which is able to get Access Token and then follow a User.
我搜索了Google,但找不到适用于PHP的代码示例?
I searched Google but i wasnt able to find a usefull code Example for PHP ?
我发现的唯一东西是这个 https://github.com/cosenary/Instagram-PHP-API
Only thing i found was this https://github.com/cosenary/Instagram-PHP-API
现在我在这里编码了这个
Now i coded this one here
error_reporting(E_ALL);
ini_set("display_errors", 1);
require 'inc/Instagram.php';
require 'inc/InstagramException.php';
use MetzWeb\Instagram\Instagram;
$instagram = new Instagram(array(
'apiKey' => 'APIKEY',
'apiSecret' => 'SECRET',
'apiCallback' => 'CALLBACK'
));
if (isset($_GET['code'])) {
// grab OAuth callback code
$code = $_GET['code'];
$data = $instagram->getOAuthToken($code);
echo 'Your username is: ' . $data->user->username;
$token= $data->access_token;
$instagram->setAccessToken($token);
echo $instagram->getAccessToken();
try {
$instagram->modifyRelationship('follow', 1399448929);
} catch (Exception $e) {
echo 'Exception abgefangen: ', $e->getMessage(), "\n";
}
}else {
$urli= $instagram->getLoginUrl(array(
'basic',
'relationships',
'likes'
));
echo "<a href=".$urli.">Login with Instagram</a>";
}
但是它不起作用...没有错误消息或其他信息,但它不在用户之后.
But it isnt working... There is no Error Message or something else but it isnt following the User.
现在我的问题:
有人知道为什么吗?...还是有人知道正确的方法来使它正常工作?
Does someone know why ? ... Or does anyone know the right way to get this working ?
请提供链接和代码示例.
Please with Links and Code Examples.
那将是葡萄
谢谢!!!
That Would be Grape
Thanks!!!
推荐答案
您可以遵循 instagramm API .我将其用于instagram登录及其对我的工作
You can follow the URL for instagramm API. I use this for instagram login and its work for me
,但您也可以检查是否遵循了用户&关系,但我认为它也会为您服务.
but you can also check for follow a User & Relationship but I think it will work for you as well.
这篇关于Instagramm API PHP关注用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!