Note that there are some explanatory texts on larger screens.

plurals
  1. PO"A user access token is required to request this resource." Facebook graph for notifications
    text
    copied!<p>NOTE: When the user accepts my permissions to use my app. I ask them to accept <code>manage_notifications</code></p> <p>I am so confused. I research this on the web and it seems I get a mix of deprecated and wrong information and I am trying to send a notification to the user using my facebook canvas app using facebook graph. the following is how I do it and its not working.</p> <pre><code>public function getAccessToken() { $app_id = $this-&gt;settings['app_id']; $app_secrete = $this-&gt;settings['app_secrete']; $url = "https://graph.facebook.com/oauth/access_token?". "client_id={$app_id}". "&amp;client_secret={$app_secrete}". "&amp;grant_type=client_credentials"; $c = curl_init($url); // necessary so CURL doesn't dump the results on your page curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($c); $result = explode("=", $result); curl_close ($c); return $result[1]; } </code></pre> <p>The result passes something like this <code>access_token=523216317ewwer235|K4A1XugBpajwrweu1K2k12jzckdU</code> . so that is why i explode the <code>=</code> sign within the code. I call this function every time the user enters my app. I take the access code and pass it as <code>$token</code> in the following code.</p> <pre><code>public function alertUser($userid,$token,$message="You have a notification") { $inviteMessage = $message; $inviteMessage = urlencode($inviteMessage); $url = "https://graph.facebook.com/{$userid}/notifications?access_token={$token}&amp;". "template={$inviteMessage}&amp;ref=notify"; $c = curl_init($url); // necessary so CURL doesn't dump the results on your page curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($c); curl_close ($c); $r = json_decode($result); } </code></pre> <p>and I get the following response</p> <pre><code>object(stdClass) { error =&gt; object(stdClass) { message =&gt; 'A user access token is required to request this resource.' type =&gt; 'OAuthException' code =&gt; (int) 102 } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload