casparjespersen
casparjespersen

Reputation: 3850

#15 Posting Notifications

I am having trouble posting a notification. This is my PHP code:

    try {
        $id = Fb_Config::get_app_id();
        $secret = Fb_Config::get_secret_code();
        $url = "https://graph.facebook.com/oauth/access_token?client_id=$id&client_secret=$secret&grant_type=client_credentials";
        $appAccessToken = end(explode("=", file_get_contents($url), 2));
        var_export(Fb_Facebook::get()->api_post("/".$this->get_logged_in_user()->get_id()."/notifications?access_token=$appAccessToken", array(
            href => "http://www.disney.com",
            template => "this is awesome"
        )));
    } catch (Exception $e) {
        echo "<pre>Error: ";
        echo $e->getMessage();
        echo "</pre>";
    }

The error is:

Error: (#15) This method must be called with an app access_token.

Upvotes: 0

Views: 41

Answers (1)

C3roe
C3roe

Reputation: 96382

Don’t make this more complicated than it has to be – the combination of app_id|app_secret (pipe symbol in the middle) works as app access token.

Upvotes: 1

Related Questions