Im using instagram api and im trying to get the access_token. I have already gotten the code and im following this steps below to get the access_token.
Now you need to exchange the code you have received in the previous step for an access token. In order to make this exchange, you simply have to POST this code, along with some app identification parameters, to our access_token endpoint. These are the required parameters:
client_id: your client id client_secret: your client secret grant_type: authorization_code is currently the only supported value redirect_uri: the redirect_uri you used in the authorization request. Note: this has to be the same value as in the authorization request. code: the exact code you received during the authorization step. This is a sample request:
curl -F 'client_id=CLIENT_ID' \
-F 'client_secret=CLIENT_SECRET' \
-F 'grant_type=authorization_code' \
-F 'redirect_uri=AUTHORIZATION_REDIRECT_URI' \
-F 'code=CODE' \
https://api.instagram.com/oauth/access_token
This is my controller below. I am trying to post the information as required to the url as requested in order to get back the access_token. However, what was return was cURL Error: SSL certificate problem: unable to get local issuer certificate. How can i fix this? Am i doing this wrong? please help thank you
public function processInstagramCode(Request $request){
$url = 'https://api.instagram.com/oauth/access_token';
$client_id = '4ffe9786b63e40f4854d767be45b9ea0';
$client_secret = '8b8ca3f5b4664777985f93a8ca38f4da';
$grant_type = 'authorization_code';
$redirect_uri='http://localhost:8000/instaPage';
$code= $_GET['code'];
$data = array(
'client_id' => $client_id,
'client_secret' => $client_secret,
'grant_type' => $grant_type,
'redirect_uri' => $redirect_uri,
'code' => $code,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
if($output === FALSE){
echo "cURL Error: " . curl_error($ch);
}
curl_close($ch);
$outputData = array(
'output' => $output
);
return view('Instagram.instaPage')->with($outputData);
}
via Desmond