views:

48

answers:

2

I see a bunch of .NET open source projects out there that look to be able to get at the users information, but I just want a user to be able to "post" media that's already on Facebook on my site as well. Other websites seem to allow you to do embedding of their media (I'm really liking oEmbed) but FB seems a bit of a mystery to me. I have no experience using their API, but I'm guessing it has something to do with the "social graph" part. Anyone else done this before? Did you use something or is this easy enough to do without these OS projects? Any examples anywhere of how someone already did this? I wouldn't think that I'm the first person to want to do this but have searched Google and didn't come up with anything.

A: 

Have you tried FQL? Using this I was able to get users display pictures on any site I wanted by simply constructing a simple SQL like query.

m.edmondson
So far haven't really tried anything, just been reading about the various methods. Seems like there's multiple ways to do things, so wasn't really sure what path to even start down.
rball
I ran stuff like https://api.facebook.com/method/fql.query?query=SELECT%20pid%20FROM%20photo%20WHERE%20aid%20IN%20%28%20SELECT%20aid%20FROM%20album%20WHERE%20owner=me%28%29%20%29%20ORDER%20BY%20created%20DESC%20LIMIT%201,42 or https://api.facebook.com/method/fql.query?query=SELECT%20src_big%20FROM%20photo%20WHERE%20pid%20IN%20%28SELECT%20cover_pid%20FROM%20album%20WHERE%20owner%20=%20me%28%29%20AND%20name%20=%20%27Profile%20Pictures%27%29 I think you're onto something but I'm only getting back <fql_query_response list="true"/>
rball
Keep trying, it was a while ago but the result set just returned a list of image files. It was something similar to "select * userimages where name LIKE 'Tony Blair'"
m.edmondson
I think maybe I have to call it from code and have an open oAuth or something session? Truly have no clue if that's correct but sure am stumped on why no queries work for me.
rball
I think it has to do with the fact that I'm using me() for the uid. My thinking was that it would insert the current user that is logged in uid. If I put a number it seems to work. What the heck is wrong with me()?
rball
A: 

The Facebook .NET SDK makes this very easy for you. You can download it here: http://facebooksdk.codeplex.com

Here is an example of how you would publish a photo using that SDK:

string photoPath = @"..\..\..\Facebook.Tests\bin\Release\monkey.jpg";
byte[] photo = File.ReadAllBytes(photoPath);

FacebookApp app = new FacebookApp();
dynamic parameters = new ExpandoObject();
parameters.message = "The message you want to go with the photo...";
var mediaObject = new FacebookMediaObject {
    FileName = "monkey.jpg",
    ContentType = "image/jpeg",
};
mediaObject.SetValue(photo);
parameters.source = mediaObject;

dynamic result = app.Api("/the_album_id/photos", parameters, HttpMethod.Post);
string photoId = result.id;
Nathan Totten
I don't really need to publish the photo, just get the list of photos that they've already put up. I think I would only need a list of photo URI's that I would allow them to choose from and then I could just link to the photo from my site. This is still cool though, I might be able to use that in the future after I get the basic stuff going.
rball