When Upload photo to Facebook with Rest API I get duplicate posts in Wall
I'm developing a Facebook app with Flash Builder where users can create 6 pictures and then publish them to their photo album.
The upload works fine but I get a different number of duplicates to my wall once the photos are published to the album. I only want to see a post to my wall with the last 3 photos that I've uploaded, in one row. What I get is sometimes 3 posts with the same photos, sometimes 4 etc... It is very weird as the post to the news feed or wall always behaves in a different way.
This is how I upload the photos
protected function uploadPhotos(event:MouseEvent):void {
var values6:Object = {caption:'caption', fileName:'FILE_NAME', image:img6};
Facebook.callRestAPI('photos.upload', handleUploadComplete6, values开发者_如何学Go6, 'POST');
var values5:Object = {caption:'caption', fileName:'FILE_NAME', image:img5};
Facebook.callRestAPI('photos.upload', handleUploadComplete5, values5, 'POST');
var values4:Object = {caption:'caption', fileName:'FILE_NAME', image:img4};
Facebook.callRestAPI('photos.upload', handleUploadComplete4, values4, 'POST');
var values3:Object = {caption:'caption', fileName:'FILE_NAME', image:img3};
Facebook.callRestAPI('photos.upload', handleUploadComplete3, values3, 'POST');
var values2:Object = {caption:'caption', fileName:'FILE_NAME', image:img2};
Facebook.callRestAPI('photos.upload', handleUploadComplete2, values2, 'POST');
var values1:Object = {caption:'caption', fileName:'FILE_NAME', image:img1};
Facebook.callRestAPI('photos.upload', handleUploadComplete1, values1, 'POST');
}
Did anyone have the same problem? I would really like to find out what is going wrong here as I can't get any help from the Facebook API documentation/forum.
Thanks
I have the exact same problem, and as far as I know, there isn't any good way to make it not happen - it seems that every time you upload a photo, there will be a wall post. It also seems (I say seems because, as you noted, this isn't covered in FB's documentation) that the number of duplicates varies according to the interval between each upload - if they're all received and published by Facebook within milliseconds of each other, it tends to only do one update, but if there's more time between each POST and response, then there are more wall posts.
I've only found two ways to deal with this -
- Remove
publish_stream
from the list of permissions you request - then your app won't trigger any wall posts. Any photos you upload for the user will be held temporarily, and the user can approve them by going to the photo album and interacting with the dialog it provides - "an app has added these photos, approve/disaprove?" sort of thing. - Go back and delete those wall posts after the fact. Get the last 10 wall posts, look at each one to determine (through album id, photo id, message text, whatever) that it's a notification regarding photos your app posted, and delete the extras. This isn't very reliable, because it needs to run after the notifications are already on the wall - and again, Facebook doesn't provide any way for you to tell when that happens.
I went with option 2 on an app I did recently, and I could make it work about 95% of the time by building in a delay between when the photos are posted, and when the user's wall is scraped for posts, then removing the photo upload notifications.
Hopefully someone else posts a better way, because this way sucks - but I suspect it might be the only way until Facebook addresses this.
I am not sure if this is related (as we are not uploading photos), but we have seen problems with wall posts being displayed multiple times over the last few days. I say "displayed" instead of "Created" because we see no evidence of duplication in any Facebook data, and the apparent duplication goes away with time.
If you have the "read_stream" permission from users, you might manually look for duplicates on their walls with a URL like this:
https://graph.facebook.com/USERID/feed?access_token=ACCESS_TOKEN
Other similar reports are here:
forum.developers.facebook.net/viewtopic.php?pid=317198
netqcreative.com/auto-post-wall-facebook/472-auto-post-facebook-is-double-posting.html
(Sorry these aren't links - I can't post multiple urls for some reason.)
Insane that posting this here seems more likely to help than posting in the Facebook forum itself...
精彩评论