Note that there are some explanatory texts on larger screens.

plurals
  1. POUpload image with facebook API
    text
    copied!<p>Question: How to upload an image from my webserver to facebook via FB API?</p> <p>I'm writing an application that retrieves images from the user's photo album, makes some modifications (e.g. adding a watermark) then send it back to photo album.</p> <p>The code I use to upload the photo is as follows</p> <pre><code>&lt;?php include_once("api/facebook.php"); include_once("config.php"); include_once("utils.php"); include_once("bemyfans.php"); $facebook=new Facebook($api_key,$app_secret); $facebook-&gt;require_frame(); $user=$facebook-&gt;require_login(); echo "&lt;p&gt;Hello &lt;fb:name useyou='false' uid=\"$user\"/&gt;&lt;/p&gt;"; $args = array( 'api_key' =&gt; $api_key, 'call_id'=&gt;microtime(true), 'v'=&gt;'1.0', 'format' =&gt; 'JSON' ); $args['Lenna.png']="@/home/thoai/htdocs/apps/bemyfans/Lenna.png"; signRequest($args,$secret); $ch = curl_init(); $url = 'http://api.facebook.com/restserver.php?method=photos.upload'; 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); if ($data = curl_exec($ch)) echo "done"; echo $data; function signRequest(&amp;$args, $secret){ ksort($args); $sig = ''; foreach($args as $k =&gt; $v){ $sig .= $k . '=' . $v; } $sig .= $secret; $args['sig'] = md5($sig); } ?&gt; </code></pre> <p>It just doesn't work. More specifically, I keep getting an "Incorrect signature" message.</p> <p>What's wrong with the code???</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