0
votes

I am working on developing WinService which uploads photos from specific folder on file system to Facebook page (to have upload, I have made Facebook application and connected it to Facebook page), where folder name is name which will be used for Facebook album. So, first I create album, which is going fine and I have album id.

I have tried several ways to upload photos to Facebook album, but each time one popup notification is generated per each uploaded photo. Way1:

FacebookClient fb = new FacebookClient(token.Trim());
//Perform upload
var imageStream = File.OpenRead(photo.Location);
fb.PostCompleted += (o, e) =>
{
    imageStream.Dispose();
    if (e.Cancelled || e.Error != null)
    {
        error = e.Error == null ? "canceled" : e.Error.Message;
    }
};
dynamic res = fb.PostTaskAsync("/" + fbAlbumID + "/photos", new
{
    message = String.Empty,
    file = new FacebookMediaStream
    {
        ContentType = "image/jpg",
        FileName = Path.GetFileName(photo.Location)
    }.SetValue(imageStream)
});
res.Wait();
var dictionary = (IDictionary<string, object>)res.Result;

way2:

dynamic result = fb.Batch(
    new FacebookBatchParameter(HttpMethod.Post, "/" + albumId + "/photos",
        new Dictionary<string, object>
        {
            {"message", "picture 1 msg"},
            {
                "pic1",
                new FacebookMediaObject {ContentType = "image/jpeg", FileName = "p4.jpg"}.SetValue(
                    File.ReadAllBytes(
                        file1path))
            }
        }),
    new FacebookBatchParameter(HttpMethod.Post, "/" + albumId + "/photos",
        new Dictionary<string, object>
        {
            {"message", "picture 1 msg"},
            {
                "pic2",
                new FacebookMediaObject {ContentType = "image/jpeg", FileName = "p4.jpg"}.SetValue(
                    File.ReadAllBytes(
                       file2path))
            }
        }
    )
);

but for each way, each uploaded photo has generated popup notification for people who have liked the page. They, "likers", see this as spam.

How to achieve to upload 10 photos in one album and to have single notification?

Please advice, thanks.

1
Where does this message come from? I don't understand... - Tobi
Which message? I have described my problem. - Ljiljana Eric
"...but each time one popup notification is generated per each uploaded photo.." - Tobi
It's displayed in bottom left corner as popup and in notifications section. Likers see that as spam, they don't want to be notified for each image. It is ok if they have one notification "10 photos uploaded to album New Year". Example of dropbox.com/s/6whtto9e4bzaovg/img.jpg - Ljiljana Eric

1 Answers

0
votes

The only way I've seen anyone accomplish this (a single feed item, or a single notification) is by using the Open Graph functionality. It really stinks that the base graph API doesn't have an easy way to do this. Whether you try a batched request (way 2), attaching a photo url, or attaching raw image data, you'll get multiple feed items and multiple notifications. Twitter's API achieves what you want by forcing you to upload multiple photos and getting back media_ids, which you can then attach to a Tweet.

See https://developers.facebook.com/docs/opengraph/using-actions/v2.2#photos. I know that setting up Open Graph may not be what you want to do, but it seems to truly be the only way at the time of this posting. Open Graph requires you to use user-level access tokens anyway, and you're using page-level tokens. So, given you're requirements, it doesn't seem to be possible yet.