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 (http://instagram.com/developer/authentication/) 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(‘https://api.instagram.com/oauth/access_token’,$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_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($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 *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>