Uploading Photos within Facebook Apps
Posted by: Auzigog in Facebook, Programming, Technology, Web design
Facebook recently released the Facebook Platform which allows developers to write applications and tools that run inside users’ profiles and within Facebook itself. So far, the Platform has been a huge success. Dozens of useful applications are coming out every day and most users are very excited for the extra functionality.
I am in the process of writing an application that brings together Flickr sets and Facebook photo albums. Unfortunately, the current implementation of the Facebook Platform lacks the ability to easily upload photos to a user’s account.
To remedy this situation, Paul Wells and I decided to writing our own addition to the Facebook PHP5 Client Library. Using it is as simple as uploading the file to your server and changing two lines of code in your existing applications. The best part is that our class does not involve code hacks at all. Our classes simply extend the current ones and add the functionality we want. The advantage to this approach is that the code will still work if Facebook updates the API.
To download the code and see an example of it’s use, visit the project page.



















Digg
Facebook
Flickr
Last.fm
MySpace
Wikipedia
YouTube
Entries (RSS)
June 24th, 2007 at 8:17 am
Hi,
Thanks for this…I’m a bit new to php (came from java bkgrd). The fb photo lib u provided works well with photo files already up on a webserver…is there a way i can get upload file from my local hd to facebook directly?
Thanks in advance.
June 24th, 2007 at 1:28 pm
You can’t upload directly from your computer. You need to use an upload form to upload it to your server, and then upload it to Facebook from there.
Here is a good tutorial on how to do that.
Good luck!
June 24th, 2007 at 7:27 pm
thanks. I will give that a shot.
Rob
June 25th, 2007 at 8:44 pm
Hi,
Another question…FB/PHP related. I was following the http://www.w3schools.com/php/php_file_upload.asp tutorial, and all is well OUTSIDE of Facebook.
So, when i was inside of facebook, i have normal html form code. When submit is pressed, the filename doesn’t seem to get pass to .php file that actually does the uploading… any idea?
Thanks again,
Rob
June 26th, 2007 at 10:54 am
I’ve never uploaded files using the Facebook Platform, but it shouldn’t be any different. You can try using
to see if your file is available anywhere.
A better place for these type of questions would be the Facebook Developers Group and the discussion board provided there.
August 23rd, 2007 at 12:07 am
Thanks for the great library.
I’m trying to use it with the php4 library and I’m having some trouble with the api_client->users_isAppAdded() function. It appears to fail and I cannot figure out why or what going on. I’m certain the php4 library works fine and your code looks like it extends the class so I’m not sure why would it effect this method.
Thanks,
Bailey
August 23rd, 2007 at 1:15 am
We never tested it with the PHP4 library, so I can’t provide any help in that regard. Sorry.
November 4th, 2007 at 5:50 am
When I use the example code provided, it doesn’t upload the image to the specified album. If I don’t specify an album, it creates a new one for my application but still doesn’t upload the image.
Any idea what could be wrong?
December 16th, 2007 at 9:42 am
Hey Guys,
Great work!
If I don’t include the following line :
$albums = $this->facebook->api_client->photos_getAlbums($user, null);
The photo gets uploaded twice. weird stuff…
March 28th, 2008 at 7:56 am
I can’t download it. When I click the download link at the http://wiki.eyermonkey.com/Facebook_Photo_Uploads page it just brings me to this blog. The link in this blog just brings me back to the other page.
Is there a working sample? Is this going to be easier than setting it up myself?
April 8th, 2008 at 1:35 pm
the link doesnt work!!
would be great, if you could made the zip available again!
thanks
April 8th, 2008 at 1:50 pm
I apologize for the file being missing for a while. I switched servers and forgot to re-upload it. It’s available for download again.
September 26th, 2008 at 3:19 pm
Were you guys going to update this any time soon to work with the new facebook stuff? It doesn’t seem to work @ all even with the code update on the project site.
October 4th, 2008 at 11:25 am
Would be great to have a working version of this function
Anyone out there know how to upload pics to an application’s album?
October 12th, 2008 at 2:43 pm
thanks for the library - implementation was a breeze!
i can’t seem to find much information about how the API interacts with FB pages(as opposed to your personal profile). does anyone know if there is a way to upload photos to an FB page (either as an admin or a fan)?