tags:

views:

365

answers:

2

I am working with the FaceBook API to upload photos, and the API requires a local file path. As far as I can tell they are handing the request off to CURL like such: upload=@localfilename

But my files don't reside locally, so I am trying to figure out if there is a way to make it work with a remote file....

I tried pointing it to a local file which just did 'echo file_get_contents('some_remote_image.jpg');'

but that didn't work.

Does anyone have any ideas?

Thanks!

A: 

You can however link to them eg

<img src="www.mydomain.com"/>

Stephen lacy
A: 

Is it not possible to cache the file on your server and then delete it after upload? I wrote a Flickr -> Facebook Photo Album app that does this very thing.

All right, well if you don't want to do that, you can do this:

Edit the file facebookapi_php5_restlib.php, tracing the photo upload calls down to the actual curl call, which is in:

private function post_upload_request($method, $params, $file, $server_addr = null)

Now the hacky part, instead of passing the filename for $file, pass in an array and then check if its an array in this function. If it is, extract the binary data from it and set it as one of the post parameters. Some curl parameters that you may need can be found here:

http://www.digimantra.com/technology/php/post-pictures-on-twitpic-api-using-php/

bertrandom
Possible, but I'm really trying to avoid it. Seems messy to download, save, upload, delete.