Sep 29, 2009

Bulk upload photos to facebook [BASH]

I got tired of uploading one photo at a time. So I googled a bit, and found few scripts but none did convince me. So I set to write one by myself. And my focus was to keep it short and simple(KISS).

The tool is a python script with following features:
* Bulk upload the pictures to facebook.
* Supports upload from specified folder or current folder (default).
* Allows to choose from available albums.

Usage:
upload2facebook [-a|--aid <album_id>] [<path>]

Install:
(Don't forget to read the notes below)
In Debian (Ubuntu, Kubuntu,...) system:
1. Install from ppa https://launchpad.net/~ssapkota/+archive/ppa
2. Install directly from deb-package -> upload2facebook_0.2_i386.deb , Package Detail

In RPM (Fedora, Centos) system
3. Install the rpm -> http://ssapkota.com.np/downloads/upload2facebook-0.2-2.i386.rpm

4. Get the source, do whatever you like -> upload2facebook_0.2.tar.gz


Note-1:
During the installation of this tool, it will ask you to enter the Application Key and Application Secret Key. To get this two key you need to register an application for yourself at facebook. Follow the following (necessary) steps:
1. Go to http://www.facebook.com/developers and click on Setup Up New Application at the top right corner.
2. Enter the Application Name (I suggest : Photo Uploader)
3. Then click Agree and then Save Changes
4. After this you will get
API Key and Secret. Copy it and save it somewhere; you'd need later. Remember, these keys are meant to be secret and shouldn't be shared (So, did I ;) ).
5. You need to do one more thing to make it work; On the left-navigation click on the Canvas and then enter a URL(may be your website/blog link) as Canvas Callback URL. I don't think this is of any use for command line application, but to make the application work you need to set this.
6. Thats it. Return to the installer and Enter your App Key and App Secret.

Note-2:
1. The tool is developed and tested in Ubuntu and works in all the Debian system.
2. The RPM package is generated using alien and have not been tested.
3. The code is written in python and is OS independent, One can easily port to any other Operation system.
4. If you have tested the tool in other system or have ported it to other OS, please post the status in the comment.

Enjoy the tool. :)

8 comments:

Manish Modi said...

Cool :)

Neil Horning said...

Using it now. Thanks.

Mike said...

Seems really handy, however, I get:

facebook.FacebookError: Error 101: Invalid API key

The installer didn't appear to make a .facebook directory with the app_id and app_secret files in so I did it myself but it still fails with the above error. Any ideas? Cheers.

Suraj Sapkota said...

Mike,

I have also seen the same error sometimes but works when I retry.
If it says Invalid API key repeatedly then for sure thats true.

Are you using RPM package?
If so I haven't tested it. And I suspect on its installer.

Eken L said...

What I have been looking for, thanks for the guide.


Let me try for my facebook in Nepal.


thanks

0xff said...

i tried ur tools and it works, however the syntax

upload2facebook -a/--aid

did not work, it returned;


Traceback (most recent call last):
File "/usr/local/bin/upload2facebook", line 193, in
execute()
File "/usr/local/bin/upload2facebook", line 141, in execute
aid=album["aid"]
UnboundLocalError: local variable 'album' referenced before assignment


What I did to make it work as for now

upload2facebook

then choose the album in the menu given

Beautiful job anyway.. easy up my life with FB!

Wrybread said...

Am I the only one not getting a list of the user's photo albums? getAlbum returns an empty list for me, even though I've confirmed that albums exist, and their permissions are set to be viewable by everyone...

Other than that, working beautifully.

I don't imagine someone else could confirm that getAlbums() still works for them?

Wrybread said...

I think I see the issue with getAlbums(), I need to grant permission to my app to read my photos and videos. I believe it's the "user_photos" permission mentioned here:

http://developers.facebook.com/docs/reference/api/permissions/

I have another app that can read my albums, and on my apps settings page (http://www.facebook.com/settings/?tab=applications) it shows "Access my photos and videos" as a permission.

Any idea how to give this permission to apps created using Py
Facebook?

But this doesn't do it:

fb.request_extended_permission( "user_photos")