Instagram API PHP 关注用户
Instagramm API PHP Follow User
目前我尝试在网站中实施 Instagramm API。
哪个能够获取访问令牌,然后关注用户。
我搜索了 Google,但找不到 PHP 的有用代码示例?
我唯一找到的就是这个
https://github.com/cosenary/Instagram-PHP-API
现在我在这里编码了这个
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>";
}
但是它不起作用...
没有错误消息或其他内容,但它没有关注用户。
所以现在我的问题是:
有人知道为什么吗? ...
或者有人知道正确的方法吗?
请提供链接和代码示例。
那就是葡萄
谢谢!!!
您可以关注 URL 以获得 instagramm API。我将其用于 instagram 登录及其对我的工作
但您也可以检查是否关注用户和关系,但我认为它也适用于您。
目前我尝试在网站中实施 Instagramm API。 哪个能够获取访问令牌,然后关注用户。
我搜索了 Google,但找不到 PHP 的有用代码示例?
我唯一找到的就是这个 https://github.com/cosenary/Instagram-PHP-API
现在我在这里编码了这个
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>";
}
但是它不起作用... 没有错误消息或其他内容,但它没有关注用户。
所以现在我的问题是:
有人知道为什么吗? ... 或者有人知道正确的方法吗?
请提供链接和代码示例。
那就是葡萄
谢谢!!!
您可以关注 URL 以获得 instagramm API。我将其用于 instagram 登录及其对我的工作
但您也可以检查是否关注用户和关系,但我认为它也适用于您。