Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Update</strong>:</p> <p>Well I can't really test it myself, so just a few suggestions what you could try. Change the <code>$loginUrl</code> to this:</p> <pre><code>$loginUrl = $facebook-&gt;getLoginUrl(array( 'req_perms' =&gt; 'publish_stream', 'next' =&gt; 'http://'.$_SERVER['SERVER_NAME'].'/success.php', 'cancel_url' =&gt; 'http://'.$_SERVER['SERVER_NAME'].'/cancel.php' )); </code></pre> <p>In the whole context, the top of the file should look like this:</p> <pre><code>require 'facebook.php'; $facebook = new Facebook(array( 'appId' =&gt; '&lt;appId removed for security reasons&gt;', 'secret' =&gt; '&lt;secret removed for security reasons&gt;', 'cookie' =&gt; true, )); $session = $facebook-&gt;getSession(); $me = null; if ($session) { try { $uid = $facebook-&gt;getUser(); $me = $facebook-&gt;api('/me'); $post = $facebook-&gt;api("/me/feed", "POST", array('message' =&gt; 'Hello! I\'m using the FB Graph API!')); } catch (FacebookApiException $e) { error_log($e); } } else { $loginUrl = $facebook-&gt;getLoginUrl(array( 'req_perms' =&gt; 'publish_stream', 'next' =&gt; 'http://' . $_SERVER['SERVER_NAME'] . '/success.php', 'cancel_url' =&gt; 'http://' . $_SERVER['SERVER_NAME'] . '/cancel.php' )); header('Location: ' . $loginUrl); } </code></pre> <hr> <p>Well, first check whether you have a session, therefore you need to configure the Facebook SDK as in the example:</p> <pre><code>$facebook = new Facebook(array( 'appId' =&gt; 'app id goes here', 'secret' =&gt; 'secret id goes here', 'cookie' =&gt; true, )); </code></pre> <p>Then you can check whether the user is logged in and your app has been authorized:</p> <pre><code>if ($facebook-&gt;getSession() == null) { // not logged in or not authorized } </code></pre> <p>In the <code>if</code>-clause you then have to do a redirect to the proper login-url to get all permissions you need:</p> <pre><code>$loginUrl = $facebook-&gt;getLoginUrl(array( 'canvas' =&gt; 1, 'fbconnect' =&gt; 0, 'req_perms' =&gt; 'publish_stream', 'next' =&gt; // url where to go when you were authorized 'cancel_url' =&gt; // url to go to when user cancelled )); header('Location: '.$loginUrl); </code></pre> <p>After you got the permissions, you can publish as mentioned in the documentation by using</p> <pre><code>$facebook-&gt;api(/* url */, array(/* additional parameters go here */)); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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