Reputation: 45
I am trying to make request to Facebook API and pass facebook_access_token to check if this token is vaild or not. I am using Laravel and guzzlehttp/guzzle": "~4.0 package to send the request as below:
public function fbLogin(Request $request)
{
try {
$fb_token = $request->input('accessToken');
$client = new Client();
$fb_url = 'https://graph.facebook.com/oauth/access_token_info?access_token='.$fb_token;
$res = $client->get('$fb_url');
return response()->Json(['data' => $res->getBody()->getContents()],200);
}catch (Exception $e) {
//catch Exception
}
}
when I call this function from Postman I get this "ClientException in RequestException.php line 71: [status code] 400 [reason phrase] Bad Request" but when I hit the same URL with the same access token I got the response from Facebook API, so any body can help in me in this issue?
Upvotes: 0
Views: 175
Reputation: 5010
First of all, switch to Guzzle 6.x. As you can see, 4.x is not supported long time already.
Then, fix error in your request:
$client->get('$fb_url');
There should be just $fb_url
(without quotes).
Upvotes: 0