Skip to content

Instantly share code, notes, and snippets.

@cosenary cosenary/follow.php
Last active Jul 23, 2018

Embed
What would you like to do?
Instagram API class - follow user example
<?php
require 'Instagram.php';
use MetzWeb\Instagram\Instagram;
$instagram = new Instagram(array(
'apiKey' => 'YOUR_APP_KEY',
'apiSecret' => 'YOUR_APP_SECRET',
'apiCallback' => 'YOUR_APP_CALLBACK' // must point to success.php
));
// set user's accesstoken (can be received after authentication)
$instagram->setAccessToken("2823787.9687902.21u77429n3r79o08233122306fa78902");
// follow user (snoopdogg)
$result = $instagram->modifyRelationship('follow', 1574083);
// receive the list of users this user follows
$follows = $instagram->getUserFollows();
// dump response object
echo '<pre>';
print_r($follows);
echo '<pre>';
@natureluvs

This comment has been minimized.

Copy link

commented May 10, 2014

when i run this,

$result = $instagram->modifyRelationship('follow', {valid user id});

// dump response object

print_r($result);

i'm getting the following error message, though my instagram profile doesn't have a link. Please help me understand what could be wrong

stdClass Object
(
[meta] => stdClass Object
(
[error_type] => APIError
[code] => 400
[error_message] => It looks like your profile contains a link (96.171.140.76) that is not allowed.
)

)

@canerd7u

This comment has been minimized.

Copy link

commented Jul 3, 2015

I get an error in the code. What is the reason ?

object(stdClass)#2 (1) { ["meta"]=> object(stdClass)#3 (3) { ["error_type"]=> string(25) "OAuthPermissionsException" ["code"]=> int(400) ["error_message"]=> string(201) "This request requires scope=relationships, but this access token is not authorized with this scope. The user must re-authorize your application with scope=relationships to be granted write permissions." } }

@random-robbie

This comment has been minimized.

Copy link

commented Jul 8, 2015

i think reading through you have to be a company to be able to do any post requests or delete.

It's hidden out the way i've nearly built my app and found this to be an issue

@devkhn

This comment has been minimized.

Copy link

commented Aug 9, 2015

Can anybody please tell me how do I get the ID?
like the ID you used here 1574083
I have never used Instagram and now I have to make an instagram app for a client. I don't know what's with the user profile IDs and how to get them. Since most users only have this username eg
username:ammarhasme

@rifkiferdian

This comment has been minimized.

Copy link

commented Aug 27, 2015

Even though you are adding scope as likes+relationships, instagram will give you basic permissions only. Instagram does not give you the permission to update relationship, post like and comments until you submit the app for review. With basic permissions you can view the people who liked your posts but you can not make like or comment to a post and can not update relationship status like follow/unfollow/block/unblock/ignore. For more details on submitting you app refer this
https://help.instagram.com/contact/185819881608116

@tiagokotryk

This comment has been minimized.

Copy link

commented Nov 26, 2016

does this follow somebody's followers?

@sansurcoder

This comment has been minimized.

Copy link

commented Mar 16, 2017

ı have a instagram follow.php like.php but the user free 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.