php - Facebook AppRequests not showing?

772

I'm using the Facebook php-sdk and the batch request API to send AppRequests with the following code:

$facebook = new Facebook(array(
    'appId' => $FB_APP_ID,
    'secret' => $FB_APP_SECRET,
    'cookie' => true
));

// get app token before it's overwritten
$FB_APP_TOKEN = $facebook->getAccessToken();

$res = $facebook->api('<USER ID>/apprequests', 'POST', array(
    'message' => 'Test message..'
), $FB_APP_TOKEN);

This appears to work and returns the ID of the request, which I can then see has been stored when looking back with the graph explorer. My problem is that nothing appears on my test user's facebook account, no notification and no number appears next to the app name in the sidebar as described here.

Does anyone have any idea why this might be?

875

Answer

Solution:

getAccessToken() sometimes don't return user access token. It only returns facebook application key. Use the following code to get the access token.

$token_url = "https://graph.facebook.com/oauth/access_token?" .
    "client_id=" . $app_id .
    "&client_secret=" . $app_secret .
    "&grant_type=client_credentials";

$app_access_token = file_get_contents($token_url);
813

Answer

Solution:

Turns out I was looking at the App's page instead of the App itself, app requests are working fine!

People are also looking for solutions to the problem: php - Keep selected fields order with HYDRATE_ARRAY in Doctrine 1.2

Source

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.