Post a Link from PHP

I have this script:
This code should post a Text and a Link to a WebSite

    <?
  // Remember to copy files from the SDK's src/ directory to a
  // directory in your application on the server, such as php-sdk/
  require_once('facebook.php');

  $c = array(
    'appId' => '4102137023*****',
    'secret' => '*****c4a60cb08*****7c0333*****',
  );

  $facebook = new Facebook($c);
  $uid = $facebook->getUser();
  echo "Userid: " . $uid;
  echo "<BR>";
?>
<html>
  <head></head>
  <body>

  <?
    if($uid){

      // We have a user ID, so probably a logged in user.
      // If not, we'll get an exception, which we handle below.
      try {
        $ret_obj = $facebook->api('/me/feed', 'POST',
                                    array(
                                      'link' => 'angel-craft.de',
                                      'message' => 'Wenn ihr das hier seht freut euch auf ein Game'
                                 ));
        echo '<pre>Post ID: ' . $ret_obj['id'] . '</pre>';

      } catch(FacebookApiException $e) {
        // If the user is logged out, you can have a 
        // user ID even though the access token is invalid.
        // In this case, we'll get an exception, so we'll
        // just ask the user to login again here.
        $login_url = $facebook->getLoginUrl( array(
                       'scope' => 'publish_stream'
                       )); 
        echo 'Please <a href="' . $login_url . '">login.</a>';
        echo $e->getType();
        echo $e->getMessage();
      }   
      // Give the user a logout link 
      echo '<br /><a href="' . $facebook->getLogoutUrl() . '">logout</a>';
    } else {

      // No user, so print a link for the user to login
      // To post to a user's wall, we need publish_stream permission
      // We'll use the current URL as the redirect_uri, so we don't
      // need to specify it here.
      $login_url = $facebook->getLoginUrl( array( 'scope' => 'publish_stream' ) );
      echo 'Please <a href="' . $login_url . '">login.</a>';

    } 

  ?>


This should post a link with a text
but the Userid($uid) stays empty

Plase Help me,

And YES this is the Demo script from FB dev.

And yes my English is not the best i am 13 years old

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories