Subject: | WWW::Facebook::API video.upload doesn't work |
Date: | Sun, 4 Oct 2009 23:56:27 -0400 |
To: | bug-www-facebook-api [...] rt.cpan.org |
From: | Anthony Bouvier <anthony [...] currentmarketing.com> |
So, I may have a bug, or just my own serious misunderstanding of how
the API works.
In the main API.pm file, there is the sub _post_request() which is
called from call()
There is a hardcoded filename ('filename') and hardcoded Content-type
('image/jpeg').
For uploading images (even non-jpegs) this is fine because Facebook
doesn't care about the Content-type or the filename actually.
However, for video, it DOES care. With those lines in API.pm, you
simple cannot currently upload video of any format. Facebook requires
a filename WITH extension -- it checks for extension first for
compatible types. So sending a hardcoded 'filename' doesn't cut it --
it will just return Error 352: Video file format is not supported.
If you change the code (which I did) to accept a passed in filename
(not the hardcoded, non-extension, 'filename') -- the video upload
works. And images still work too.
This is probably all happening because video.upload changed somehow
since the release of the CPAN module.
A few other notes:
I had to set format => 'XML' for it to even start communicating --
Facebook was sending XML back and since JSON is the module's default,
it was choking.
Also worth noting in your documentation for newbies, in order to use
video.upload you have to point to a different URL:
http://api-video.facebook.com, and not api.facebook.com (the module's
default). That's not a bug of course, just a helpful hint that could
maybe go in the POD.
I'm sure it is trivial, but if it would be helpful, I can share the
code I had to hack into place in API.pm and also how I called it from
my script.
--
Anthony Bouvier
Geek In Charge
1324 E. Washington Street
Louisville, Kentucky 40206
Direct: 502.561.2422
Twitter: http://twitter.com/thebouv
Facebook: http://facebook.com/thebouv