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 apps.facebook.com/appname url
Any ideas?
The second way i am trying is :
$token_url = 'https://graph.facebook.com/oauth/access_token?'
. '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.
Answer
Solution:
The 2nd method returns what looks like Facebooks new encrypted access token and is probably just fine. Have you tested it out. https://graph.facebook.com/me?access_token={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.