Instagram curl -F to request an access_token

I have been working with the Instagram API for my client project, So below is the code snippet to get userid (if user logged with instagram).
I got the reference code from here ( and the below one is i have tried with the php language.

Info about Curl -F -> curl is a linux utility that simulates web requests. Issuing a curl -F command issues a http request with form submission data.

$curl_attr = array(“client_id”=>$instagram_client_id, “client_secret”=>$instagram_client_secret, “grant_type”=>”authorization_code”, “redirect_uri”=>”Your Redirect URI”,”code”=>$insta_access_code);

$curl_output = curl_download(‘’,$curl_attr);

function curl_download($Url,$fields){
$fields_string = “”;
if (!function_exists(‘curl_init’)){
die(‘Sorry cURL is not installed!’);
foreach($fields as $key=>$value) { $fields_string .= $key.’=’.$value.’&’; }
rtrim($fields_string, ‘&’);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
return $output;

I will update this post with full api soon.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.