Note that there are some explanatory texts on larger screens.

plurals
  1. POfacebook create app for page to upload photos to page's photo album
    text
    copied!<p>I'm completely new to Facebook app development, so please bear with me.</p> <p>I've been asked to create a Facebook Page, with an application that will let users upload photos into one of the Page's albums.</p> <p>I've managed to create the page, let's call it <code>MyPage</code>. I've also created an app <code>MyApp</code>, and I've added the App to the profile of the Page. Now, when you view <code>MyPage</code> profile, on the left (tabs), you will already find <code>MyApp</code>.</p> <p><code>MyApp</code> points to a php page on my hosting account. It has a form with a file field:</p> <pre><code>&lt;form action="&lt;?=$PHP_SELF;?&gt;" enctype="multipart/form-data" method="post"&gt; &lt;input name="MAX_FILE_SIZE" type="hidden" value="10000000" /&gt; &lt;input id="fileSelect" name="fileSelect" type="file" /&gt; &lt;input name="submit" type="submit" value="Upload" /&gt; &lt;/form&gt; </code></pre> <p>and the following code to handle the uploaded file and supposedly put into <code>MyPage</code>'s album:</p> <pre><code>if(count($_FILES)){ $name = ereg_replace(' ', '_', basename($_FILES['fileSelect']['name'])); $uploadFile = "uploads/" . $name; if (move_uploaded_file($_FILES['fileSelect']['tmp_name'], $uploadFile)) { $facebook-&gt;setFileUploadSupport(true); $args = array('message' =&gt; 'Photo Caption'); $args['image'] = '@' . realpath($uploadFile); $data = $facebook-&gt;api('/THE_ALBUM_ID/photos', 'post', $args); //get rid of the original on the main server unlink($uploadFile); } } </code></pre> <p>However, when the "Upload" button is submitted, I get this error, right in <code>MyPage</code>'s iframe for <code>MyApp</code>:</p> <pre><code>Fatal error: Uncaught OAuthException: (#120) Invalid album id thrown in /COMPLETE_PATH/facebook-php-sdk/src/base_facebook.php on line 1033 </code></pre> <p>Even tho the album id is really correct, and displays when I use Graph API Explorer, or <code>graph.facebook.com/THE_ALBUM_ID</code></p> <p>By the way, I put this on top of the script:</p> <pre><code>require 'facebook-php-sdk/src/facebook.php'; $facebook = new Facebook(array( 'appId' =&gt; 'THE_APP_ID', 'secret' =&gt; 'THE_APP_SECRET', )); </code></pre> <p>What am I missing? Any help would be much appreciated.</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