php - Cant get app access token


Im desperately trying to get the app access token and failing miserably. Perhaps someone code help

The first way i am trying to get is below :

try {
    $access_t = $facebook->api(
        '/oauth/access_token', 'get', array(
            'client_id'     => $app_id,  
            'client_secret' => $app_secret, 
            'redirect_uri'  => $canvas_page_url
} catch (FacebookApiException $e) {
    echo $e;

I get the error "AuthException: An unknown error has occurred." I confess im not sure what url i should be using for $canvas_page_url So i have used my url

Any ideas?

The second way i am trying is :

$token_url = ''
    . 'client_id=' . $app_id
    . '&client_secret=' . $app_secret
    . '&grant_type=client_credentials';

And although this does return a access token i am reading that in fact its wron g... Not long enough?

result = 248119721897385|LvWcoYbWu2lQlkEN0HDOeIupSqs

Any ideas on this would be really appreciated as its been doing my head in for some time now.




The 2nd method returns what looks like Facebooks new encrypted access token and is probably just fine. Have you tested it out.{your access token}

I'm guessing it will work just fine for things the app token has access to do. For some operations you'll need other types of tokens like the user token.

People are also looking for solutions to the problem: Grouping multidimensional arrays in PHP by field


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.