Note that there are some explanatory texts on larger screens.

plurals
  1. POfacebook upload photo
    primarykey
    data
    text
    <p>I'm new to the facebook api, and i have a small issue. I'm trying to upload a picture to an album of an user. For this i'm using a PHP script i've found here, on stack overflow :</p> <pre><code> $app_id = xxx; $app_secret = "xxx"; $my_url = "http://apps.facebook.com/myapp/test.php"; $code = $_REQUEST["code"]; if(empty($code)) { $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&amp;redirect_uri=" . urlencode($my_url); echo("&lt;script&gt; top.location.href='" . $dialog_url . "'&lt;/script&gt;"); } $token_url = "https://graph.facebook.com/oauth/access_token?client_id=" . $app_id . "&amp;redirect_uri=" . urlencode($my_url) . "&amp;client_secret=" . $app_secret . "&amp;code=" . $code; $access_token = file_get_contents($token_url); //upload photo $file= 'test.png'; $args = array( 'message' =&gt; 'Photo from application', ); $args[basename($file)] = '@' . realpath($file); print_r($args); $ch = curl_init(); $url = 'https://graph.facebook.com/2038278/photos?access_token='.$access_token; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $args); $data = curl_exec($ch); //returns the photo id print_r(json_decode($data,true)); </code></pre> <p>But the result is :</p> <blockquote> <p>Array ( [message] => Photo from application [test.png] => @/[mypath]/test.png ) Array ( [error] => Array ( [type] => OAuthException [message] => Error validating application. ) )</p> </blockquote> <p>What does this mean ? Do i need to have extended permissions for my app ?wich of them ? i gave it acces to basic and user_photos</p> <p>Thank you very much!</p> <hr> <p>the second script</p> <p>$app_id = "xxx"; $app_secret = "xxx"; $my_url = "http://apps.facebook.com/myapp/test.php";</p> <pre><code>$code = $_REQUEST["code"]; if(empty($code)) { $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&amp;redirect_uri=" . urlencode($my_url) . "&amp;scope=user_photos" ; echo("&lt;script&gt; top.location.href='" . $dialog_url . "'&lt;/script&gt;"); } $token_url = "https://graph.facebook.com/oauth/access_token?client_id=" . $app_id . "&amp;redirect_uri=" . urlencode($my_url) . "&amp;client_secret=" . $app_secret . "&amp;code=" . $code; $access_token = file_get_contents($token_url); $token = $access_token; //upload photo $file= 'test.png'; $args = array( 'message' =&gt; 'Photo from application', ); $args[basename($file)] = '@' . realpath($file); $ch = curl_init(); $url = 'https://graph.facebook.com/me/photos?access_token='.$token; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $args); $data = curl_exec($ch); print_r(json_decode($data,true)); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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