Iam using oriceon/oauth-5-laravel for connecting with instagram.I authenticated and i got my name and id by through this request
$result = json_decode($instagramService->request('users/self'), true);
Now i want to follow a person by using this oriceon/oauth-5-laravel.
How i could post the request to follow a person by using this .
**NOTE:**dont refer the instagram developer page.I reffred it a lot.But i couldnt put a post request for ORICEON/laravel oauth wrapper for instagram.
HELP ME.TYSM in advance
try this .Copy this method to your controller and do proper routing.
public function followWithInstagram(Request $request)
{
$instagram_id='id of the user that you want to follow';
$code = $request->get('code');
$instagramService = \OAuth::consumer('Instagram');
if ( ! is_null($code))
{
$state = isset($_GET['state']) ? $_GET['state'] : null;
$instagramService->requestAccessToken($code, $state);
$linkData = [
'action' =>'follow',
];
$result =json_decode($instagramService->request('https://api.instagram.com/v1/users/'.$instagram_id.'/relationship','POST',$linkData),true);
if(!$result){
return ("Failed");
}
else {
return ("SUCCESS");
}
} else {
$url = $instagramService->getAuthorizationUri();
return redirect((string)$url);
}
}