Context : Facebook-Java API usage for uploading photos.
Problem : You get error "Incorrect Signature" while doing client.photos_upload with caption as one of the parameter. This happens when you have caption with
more than one words or any special character.
Reason: In FacebookRestClient.java : postFileRequest method it encodes all the form data. So when you send caption with photo, it URL encodes the caption also. One word caption is fine , but if you have more than one word "my buddies" will be encoded and result will be "my%20buddies" which Facebook does not like at the receiving end. Have a look at their documentation for photos upload.
Solution: Simple brute force solution is not to send caption encoded. Drop following line in postFileRequest method
if (entry.getKey()!=null && entry.getKey().equals("caption"))
doEncode = false;
right before following line out.writeBytes(doEncode? encode(entry.getValue()): entry.getValue().toString());
compile the Facebook source again , bundle the jar file and you are done.
BTW, I have not really looked their bug list or discussion forum , they might have a better solution for this but thought would share this for people who want to know what the issue is when they see this error "Incorrect Signature" , which is completely misleading.
Another effort to save someone's day.
Blogged with MessageDance using Gmail