Note that there are some explanatory texts on larger screens.

plurals
  1. POIssues with sessions on Facebook PHP SDK
    text
    copied!<p>I want to make in my site buttons that <code>onclick</code> will post on user facebook wall a message. I call an AJAX script from php pages in my site that send the message in _POST to the php file with the facebook code.</p> <p>I'm getting this ERROR while running my php file:</p> <blockquote> <p>Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/user/public_html/fb/index.php:1) in /home/user/public_html/fb/facebook.php on line 49</p> </blockquote> <p>my PHP look like this:</p> <pre><code>&lt;?php include('../ilink.php'); //mysqli connection $fb_message=$_POST['fb_message']; $fb_description=$_POST['fb_description']; $fb_picture=$_POST['fb_picture']; require 'facebook.php'; // Create our Application instance. $facebook = new Facebook(array( 'appId' =&gt; '--appid--', 'secret' =&gt; '--secret--', 'cookie' =&gt; true )); $user = $facebook-&gt;getUser(); if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook-&gt;api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } // Login or logout url will be needed depending on current user state. if ($user) { $logoutUrl = $facebook-&gt;getLogoutUrl(); } else { $loginUrl = $facebook-&gt;getLoginUrl(); } $attachment = array('message' =&gt; $fb_message, 'name' =&gt; 'text', 'caption' =&gt; 'text', 'link' =&gt; 'http://www.domain.com', 'description' =&gt; $fb_description, 'picture' =&gt; $fb_picture, 'actions' =&gt; array(array('name'=&gt;'text', 'link' =&gt; 'http://www.domain.com'),) ); $result = $facebook-&gt;api('/me/feed/','post',$attachment); ?&gt; </code></pre> <p>my ajax script:</p> <pre><code> function fb_post(fb_message,fb_description,fb_picture,redirect){ var xmlhttp; if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else{// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200){ document.location.href =redirect;  } } var q="fb_message="+fb_message+"&amp;fb_description="+fb_description+"&amp;fb_picture="+fb_picture; xmlhttp.open("POST","/fb/index.php",true); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xmlhttp.send(q); } </code></pre> <p>Why the ERROR appear?</p>
 

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