title: Facebook PHP SDK get access token using php
body: <p>I am using the following code to post to Facebook:  </p>
  
  <pre><code>require('facebook.php');
  
  $fb = new Facebook(array('appId' =&gt; 'MY APP ID','secret' =&gt; 'MY APP SECRET','cookie' =&gt; true));
  
  $result = false;
  $feed_dir = '/401868882779/feed/';  //to the UID you want to send to
  $acToken = "MY ACCESS TOKEN";
  $url = 'URL';
  $link = $url . 'event.php?id=' . $id;
  if (isset($picture))
  {
      $picture = $url . 'uploads/' . $picture;
  }
  else
  {
      $picture = $url . 'images/blank100x70.png';
  }
  $msg_body = array('access_token' =&gt; $acToken,'name' =&gt; $noe_unsecured,'message' =&gt; $link,'link' =&gt; $link,'description' =&gt; $description_unsecured,'picture' =&gt; $picture);
  
  try
  {
      $result = $fb-&gt;api($feed_dir, 'post', $msg_body);
  } 
  catch (Exception $e)
  {     
          $err_str = $e-&gt;getMessage();
  }
  </code></pre>
  
  <p>but I need to update the access token manually every time it changes. I am sure there's solution but I cant find it.. I tried lots of scripts and nothing worked.</p>