Home > Computers, Programming > Uploading Photos within Facebook Apps

Uploading Photos within Facebook Apps

Facebook Platform LogoFacebook 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.

Computers, Programming

  1. rob
    June 24th, 2007 at 08:17 | #1

    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.

  2. admin
    June 24th, 2007 at 13:28 | #2

    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!

  3. rob
    June 24th, 2007 at 19:27 | #3

    thanks. I will give that a shot.

    Rob

  4. rob
    June 25th, 2007 at 20:44 | #4

    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

  5. admin
    June 26th, 2007 at 10:54 | #5

    I’ve never uploaded files using the Facebook Platform, but it shouldn’t be any different. You can try using

    print_r($_REQUEST);

    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.

  6. August 23rd, 2007 at 00:07 | #6

    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

  7. admin
    August 23rd, 2007 at 01:15 | #7

    We never tested it with the PHP4 library, so I can’t provide any help in that regard. Sorry.

  8. Courtland
    November 4th, 2007 at 05:50 | #8

    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?

  9. aaron
    December 16th, 2007 at 09:42 | #9

    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…

  10. Mamboozle
    March 28th, 2008 at 07:56 | #10

    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?

  11. ahmed
    April 8th, 2008 at 13:35 | #11

    the link doesnt work!!

    would be great, if you could made the zip available again!

    thanks

  12. admin
    April 8th, 2008 at 13:50 | #12

    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.

  13. September 26th, 2008 at 15:19 | #13

    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.

  14. Carlos
    October 4th, 2008 at 11:25 | #14

    Would be great to have a working version of this function :(

    Anyone out there know how to upload pics to an application’s album?

  15. Ari
    October 12th, 2008 at 14:43 | #15

    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)?

  16. Andreas Novier
    February 14th, 2009 at 22:46 | #16

    Hi,
    I’m from Indonesia.i’m sorry if my english is bad.I have s60 phone (n3230).In its gallery,there is upload photo facility.When i choose it,a dialog said,”No image server defined.Define one now?”.Is it can able us to upload photos to our Facebook account?If can,what is the address ‘web server’that we must fill in image server setting?Thanks a lot and i hope there will be an answer to me about this.

  17. May 18th, 2009 at 01:05 | #17

    Hello,
    I am creating an application in Facebook, one of the functionality is to upload an image. When I do so, I do not get anything in $_FILES array.
    Please help.

  1. No trackbacks yet.