I
I
Irina2015-04-14 16:03:11
PHP
Irina, 2015-04-14 16:03:11

Facebook access token - how to solve the problem?

Hello!
Faced a problem. When I request a token, I get it as a hash tag in response.
How can I get a token as a parameter?
Now I do this:

https://www.facebook.com/dialog/oauth?client_id=[client_id]&client_secret=[secret_key]&redirect_uri=[redirect_uri]&response_type=token

In response I get:
http://me_site.com/fb.html?#access_token=CAAXgUbOqk5kBAKuPxupfOFXeAbV...

Naturally, we will not find an access_token in the request, but it is needed to work with curl.
Of course, I understand that in order to get the token we need, we need to use response_type=code, but when we received it, we get an error when requesting FB.
e28e1eddb93940c79fecda95be05e58e.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergej, 2015-04-14
@IrishkaDeutsch

You understand everything correctly.
You need to use code instead of token.
Once we got the token, we do something like:

$token_url = "https://graph.facebook.com/oauth/access_token?"
            . "client_id=" . $client_id . "&redirect_uri=" . urlencode($redirect)
            . "&client_secret=" . $secret . "&code=" . $code;
// $code - ранее полученный код-токен
$response = file_get_contents($token_url);
//...
// теперь $response содержит ваш токен.

Z
zyaleniyeg, 2015-04-14
@zyaleniyeg

get with javascript and redirect to the same url with GET transmission

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question