Got nothing return after post curl to Box to access token
Hi everybody, I already setup my App and try to test some common function such as get access token.
This is my code, it return nothing.
Note: I tested on my local development 127.0.0.1 is this restrict?
$url = 'https://api.box.com/oauth2/token';
//$url = 'http://dev.test.com/test-return.php';
$fields = array(
'grant_type' => 'authorization_code',
'code' => '5XWSYYpUMgirolzliSoov1nEveZ6EbZY',
'client_id' => '4tfx0e8c4zknuoxtwyrcnto6k4uhrktn',
'client_secret' => 'wx5oNyMyhIgHIyD2DMNoH5dh0Zvj7QKX'
);
try {
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
/*curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer '.$token,
'Content-Type:multipart/form-data'
));*/
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$response = curl_exec($ch);
curl_close($ch);
} catch (Exception $e) {
$response = $e->getMessage();
}
echo '
Response is:
';//echo $response;
print_r($response);
?>
Anyone could help me please, thank you.
Please sign in to leave a comment.
Comments
0 comments