質問

I am trying to send notification to one of my users but I have a error

[error] => Array
            (
                [message] => Invalid OAuth access token signature.
                [type] => OAuthException
                [code] => 190
            )

I am using this code:

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

$app_token = file_get_contents($token_url);

$params = array(
    'href' => APP_URL,
    'access_token' => $app_token,
    'template' => 'ble ble ble'        
);

$result = $facebook->api('/me/notifications/', 'post', $params);

$app_token return -> access_token=273347866145980|gIdxLQBHtPEHPf1Bjnw2MtnOqfA

What am I doing wrong?

Maybe someone knows the solution?

役に立ちましたか?

解決

access_token=273347866145980|gIdxLQBHt… – that’s not the token, only the second part is – so you have to split this string at the = character, and only use the second half as the actual token.

But the combination app_id|app_secret, pipe symbol in the middle always works as app access token, so there is no real need to request a token with an API call before. And this is also the token the PHP SDK builds and automatically uses itself when no user access token is available.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top