Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook post on page with PHP SDK
    primarykey
    data
    text
    <p>I'd like to post on page - throught my site. . I didn't find anything that could help me in documentation. Also none of google results gave mi answer.</p> <pre><code>function post_facebook($data=null){ $result = ""; require_once (ROOT. "/apps/configuration/models/ConfigurationItem.php"); require_once (ROOT . "/components/facebook/facebook.php"); $this-&gt;ConfigurationItem = new ConfigurationItem($this-&gt;getContext()); $row=$this-&gt;ConfigurationItem-&gt;findByCatKeyItemKey('system','facebook_login'); $apiid=$row['value']; $row=$this-&gt;ConfigurationItem-&gt;findByCatKeyItemKey('system','facebook_pass'); $secret=$row['value']; $facebook = new Facebook(array( 'appId' =&gt; $apiid, 'secret' =&gt; $secret, 'cookie' =&gt; true, )); $session = $facebook-&gt;getSession(); print_r($session); $me = null; if ($session) { try { $uid = $facebook-&gt;getUser(); $me = $facebook-&gt;api('/me'); } catch (FacebookApiException $e) { error_log($e); } $message=$data['facebook_text']; $attachment = array( 'message' =&gt; $data['facebook_text'], 'name' =&gt; $data['name'], 'link' =&gt; $this-&gt;getLinkToLatestNews(), 'description' =&gt; '', ); if($data['thumb_file_tree_id'] !== NULL) $attachment = $_SERVER['HTTP_HOST']."media/file/image_by_id/".$data['thumb_file_tree_id']."/?w=400&amp;amp;h=500"; try { $facebook-&gt;api('/162618213751448/feed/', 'post', $attachment); $result = "Facebook: Sent"; } catch (FacebookApiException $e) { $result = "Facebook: Failed"; error_log($e); } } else { $login_url = $facebook-&gt;getLoginUrl(); header("Location: ".$login_url); exit; } return $result; } </code></pre> <p>The wrong part is:</p> <pre><code>$session = $facebook-&gt;getSession(); $me = null; if ($session) { (...) } else { $login_url = $facebook-&gt;getLoginUrl(); header("Location: ".$login_url); exit; } </code></pre> <p>I want to allow user to login on specified FB account (this with page), and then send. App settings allow only this account to post, so it should be ok... But isn't. When I log out FB account, session still exists, but returns exception. What's wrong?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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