Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

me/feed with pic from different domain

I was trying to find this on facebook's site in their documentation but so far no luck. I'm sure others must have run into this before.

I use Amazon S3 for storing images. I didn't know ahead of time that if I named my bucket as my domain name with subdomain I could link that way, so until I move all of the pictures I have to link to mybucket.s3.amazonaws.com domain. When I include a picture from there with a post to the wall the picture doesn't show up. If I change the picture to one on the server itself the picture does show up. It seems that the domain name of the picture must match my app? I looked at bugzilla and didn't see this mentioned. Facebook's forum says to post questions here.

I'm using the C# Facebook SDK from CodePlex.

My code looks like (with error handling and authentication check removed):

        var client = new FacebookClient(FACEBOOK_APP_ID, FACEBOOK_SECRET);
        client.AccessToken = facebook.AccessToken;
        var parameters = new Dictionary<string, object>();
    parameters.Add("name", name);
        parameters.Add("caption", title);
        parameters.Add("message", message);
        parameters.Add("link", link);
        parameters.Add("source", link);
        parameters.Add("picture", imageUrl);
        client.Post("me/feed", parameters);

I verified that imageUrl does indeed have a correct picture, the domain name just doesn't match. The picture on amazon s3 has public read access. I can view it from my browser so I don't think it's a permission problem. I've tried a few different pictures with the same problem. Only time it's worked so far is when the picture was on the server itself.

So, my question is, is it a problem with me, or does facebook block images that don't match the domain name specified on the app?

like image 453
GregInWI2 Avatar asked Aug 27 '11 00:08

GregInWI2


2 Answers

You can upload the picture from that url, then add its object id in the post.

Refer to: http://developers.facebook.com/blog/post/526/?ref=nf

Uploading Photos to the Graph API via a URL

Earlier this year, we released support for uploading photos directly via the Graph API. This requires sending the photo as a MIME-encoded form field. We are now enhancing our photo upload capability by introducing the ability to upload photos simply by providing a URL to the image. This simplifies photo management for a number of use cases:

  • App developers who host their images on Amazon S3 or a similar
    service can pass the S3 URL directly to Facebook without having to
    download the file to their application servers only to upload it
    again to Facebook. This improves performance and reduces costs for
    developers.
  • Apps written on platforms that don't have good support for multipart file uploads can create new photos more easily.

To upload a photo via a URL, simply issue an HTTP POST to ALBUM_ID/photos with the url field set to the URL of the photo you wish to upload. You need the publish_stream permission to perform this operation. You can also include an optional message parameter to set a caption for the photo.

like image 145
ShawnDaGeek Avatar answered Nov 01 '22 06:11

ShawnDaGeek


I'am facing the same issue as well. Based on my observations it seems that facebook does not like it when the picture url has more than one sub-domain.

I tried the below 2 URL variations for the same image..

mybucket.s3.amazonaws.com - throws an error

s3.amazonaws.com/mybucket - works fine

:picture => 'http://mybucket.s3.amazonaws.com/footprints/15/coverimgs/medium.jpg'
OAuthException: (#100) picture URL is not properly formatted

:picture => 'http://s3.amazonaws.com/mybucket/footprints/15/coverimgs/medium.jpg'
{"id"=>"587472956_10150280873767957"}

Now i have to figure out how to change the URL structure for the image while passing it to the FB graph API.

like image 4
saravanak Avatar answered Nov 01 '22 06:11

saravanak