Note that there are some explanatory texts on larger screens.

plurals
  1. POOffline upload photo to Facebook with photo from web server
    primarykey
    data
    text
    <p>I've searched around everywhere without luck and found lots of examples to upload a photo to facebook when the user is in a session (i.e. the user is physically sitting at the computer and accessing the web page). I've tried the samples, and they work.</p> <p>I noticed this unanswered question from last year on the same issue <a href="https://stackoverflow.com/questions/3220434/php-upload-a-web-hosted-photo-to-facebook-album-via-graph-api">Stackoverflow Question</a></p> <p>My current app lets the user authorise off-line updates and I store the access_token, user_id, etc. and I can succesfully post to a users wall when they are offline.</p> <p>I'm really struggling getting something to work with posting a photo to the users wall. Reading the <a href="http://developers.facebook.com/docs/reference/api/photo/" rel="nofollow noreferrer">Facebook documentation</a>, I'm thinking you can only upload photos using multipart/form-data!?!?</p> <p>That wouldn't work if the user isn't at their computer. Can you upload photos that are stored on a directory on my server?</p> <p>Here's my code so far. Remember, this doesn't use a facebook session as the access_code has already been granted and stored beforehand. As I mentioned, posting to a users wall already works with this approach.</p> <pre><code>$filename= "@/myphotodir/filename.jpg"); $url = "https://graph.facebook.com/".$uid."/photos"; //$uid is fb user id $ch = curl_init($url); $attachment = array('access_token' =&gt; $access_token, 'app_id' =&gt; $app_id, 'name' =&gt; "A photo from me...", 'fileUpload' =&gt; true, 'message' =&gt; "my message", 'image' =&gt; $filename, ); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result= curl_exec($ch); curl_close ($ch); </code></pre> <p>Edit: $result comes back false... forgot to add that.</p> <p>Any help would be appreciated. Many thanks, Dean</p>
    singulars
    1. This table or related slice is empty.
    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