title: How to post to friends wall automatically using Facebook PHP SDK
body: <p>Is it possible to post to a friends wall/timeline in facebook using an app even if the user is not currently logged in? Here's the code that I'm currently working on, as you can see it posts a message on a friends wall(substitute the friend_id with an actual profile id). This works but a user has to logged in in order to perform this operation.
  I don't have any idea what to do if I want this script to execute automatically(without user intervention).</p>
  
  <pre><code>&lt;?php
  require 'php_sdk/src/facebook.php';
  
  $facebook = new Facebook(array(
    'appId'  =&gt; 'XXX',
    'secret' =&gt; 'XXX',
  ));
  
  $session = $facebook-&gt;getUser();
  $me = null;
  
  if($session){
      try{
          $me = $facebook-&gt;api('/me');
  
          $facebook-&gt;api('/friend_id/feed', 'post', array('message'=&gt;'hello without user!'));
  
      }catch(FacebookApiException $e){
          echo $e-&gt;getMessage();
      }
  }
  
  if($me){
      $logoutUrl = $facebook-&gt;getLogoutUrl();
      echo "&lt;a href='$logoutUrl'&gt;Logout&lt;/a&gt;";
  }else{
      $loginUrl = $facebook-&gt;getLoginUrl(array(
          'scope' =&gt; 'user_about_me,user_birthday,user_location,email,read_friendlists,friends_location,friends_birthday,publish_stream'
      ));
      echo "&lt;a href='$loginUrl'&gt;Login&lt;/a&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p>Any ideas? Code samples, and links to specific documents that can help me gain a bit of idea on how this works is greatly appreciated thanks!</p>