title: Facebook Photo Posting App Doesn't Work?
body: <p>I used a Facebook Developers script called "Upload photos to a User's profile" (check it out : <a href="https://developers.facebook.com/docs/php/howto/uploadphoto" rel="nofollow">https://developers.facebook.com/docs/php/howto/uploadphoto</a>) but it doesn't work...</p>
  
  <p>Here's my code :</p>
  
  <pre><code>&lt;?php
    // 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/src/facebook.php');
  
    $config = array(
      'appId' =&gt; 'I_ENTERED_MY_APP_ID_HERE',
      'secret' =&gt; 'I_ENTERED_MY_APP_SECRET_HERE',
      'fileUpload' =&gt; true,
      'allowSignedRequest' =&gt; false // optional but should be set to false for non-canvas apps
    );
  
    $facebook = new Facebook($config);
    $user_id = $facebook-&gt;getUser();
  
    $photo = '/pictures/1.jpg'; // Path to the photo on the local filesystem
    $message = 'Look at this picture I just uploaded !';
  ?&gt;
  &lt;html&gt;
    &lt;head&gt;&lt;/head&gt;
    &lt;body&gt;
  
    &lt;?php
      if($user_id) {
  
        // We have a user ID, so probably a logged in user.
        // If not, we'll get an exception, which we handle below.
        try {
  
          // Upload to a user's profile. The photo will be in the
          // first album in the profile. You can also upload to
          // a specific album by using /ALBUM_ID as the path 
          $ret_obj = $facebook-&gt;api('/me/photos/', 'POST', array(
                                           'source' =&gt; '@' . $photo,
                                           'message' =&gt; $message,
                                           )
                                        );
          echo '&lt;pre&gt;Photo ID: ' . $ret_obj['id'] . '&lt;/pre&gt;';
          echo '&lt;br /&gt;&lt;a href="' . $facebook-&gt;getLogoutUrl() . '"&gt;logout&lt;/a&gt;';
        } 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-&gt;getLoginUrl( array(
                         'scope' =&gt; 'photo_upload'
                         )); 
          echo 'Please &lt;a href="' . $login_url . '"&gt;login.&lt;/a&gt;';
          error_log($e-&gt;getType());
          error_log($e-&gt;getMessage());
        }   
      } else {
  
        // No user, print a link for the user to login
        // To upload a photo to a user's wall, we need photo_upload  permission
        // We'll use the current URL as the redirect_uri, so we don't
        // need to specify it here.
        $login_url = $facebook-&gt;getLoginUrl( array( 'scope' =&gt; 'photo_upload') );
        echo 'Please &lt;a href="' . $login_url . '"&gt;login.&lt;/a&gt;';
  
      }
  
    ?&gt;
  
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When I refresh my website page, it doesn't upload the image in my database to my wall... Can anyone tell me what's the problem..?</p>