I am building an application where users will upload photos which will be stored in an album on their Facebook account. Currently, I am using the C# SDK to achieve this, and I managed to get the photo uploaded.
When I tried to query the photo using the following FQL in the Graph API explorer:
select object_id, like_info from photo where object_id=[my_object_id]
I get the following result:
{
"data": [
{
"object_id": "11111111111111111",
"like_info": {
"can_like": false,
"like_count": 0,
"user_likes": false
}
}
]
}
Uploading a photo by posting directly to the Graph API endpoint https://graph.facebook.com/me/photos?access_token=[my_access_token] and doing a FQL on the resulting ID gives the same result - the can_like has a value of false. On both occasions, the "Who can see posts this app makes for you on your Facebook timeline?" setting for the app was set to "Public".
If I view the photo page, I can see the photo but there are no "Like" or "Comment" buttons. Upon further investigation, I found that the "Like" and "Commment" buttons will only appear if I (or rather my access token's user) is a friend of the uploader. Is it possible to make the uploaded photo "Likeable"? My objective is to allow users who come to my app to be able to "Like" the individual photos without having to be a friend of the person who uploaded it. Can this be achieved or am I missing something? Thanks.
This is restriction of facebook, but i have found a workaround, when user have their subscriptions enabled here: https://www.facebook.com/about/subscribe anyone can like/comment their photos...
Related
I've been searching the Graph API Explorer and documentation for a long time, but I really can't find anything.
I need a simple GET request like the me/subscribes just with page-id/subscribers or something like that. Does anyone know the get I must send to get a Count of subscribers of a page?
BTW I'm using Facebook SDK and I'm using this as GET:
var fb = new FacebookClient(useraccesstoken);
dynamic result = fb.Get("i want to get subscribers of a page id what to do??");
The /me/subscribers end-point was available to users' only, and has since been removed with Graph API 2.0, along with the user_subscriptions permission.
You can get a count of the subscribers / likes for a page as follows:
/{page-id}?fields=likes
This will return an a count for the total number of likes for a given {page-id}:
{
"likes": 123456,
"id": "{page-id}"
}
Trying to access the subscribers of a page is the same as trying to access all the users that have liked the page, which Facebook doesn't allow.
I am using ASP.net C# for a web application that integrates with the Facebook API. My application will allow users to create a group for sharing code. I need to use Facebook API to let the user invite friends from Facebook to join his group on my application. This is a requirement for an assignment so please don't give suggestions to create a group of users that are registered with my site only.
Until now I have the request dialog with all the friends listed (MultiFriendSelector()) with this code:
<p> Click <span id="span-link" onclick="sendRequestViaMultiFriendSelector(); return false;">here</span> to add friends from your Facebook account to your group! </p>
But I am stuck on how to get the id's and details of these invited users so I can save them in my database and allow them to access the group they were invited to. How can I do this please? I can't seem to find anything related to this.
By the way I know that there is a related question which gives this code:
if( Request["ids"] != null )
((Site)Master).FbInviteSent(Request.QueryString.GetValues("ids"));
but I don't know what Master is and I cant get it to work.
Thanks for your help :)
Whenever you call the request dialog, you may pass a callback function:
function sendRequestViaMultiFriendSelector() {
FB.ui({method: 'apprequests',
message: 'My Great Request'
}, requestCallback);
}
The requestCallback will receive the response, and this response returns the facebook id of the users, who were invited
function requestCallback(response){
for (var i = 0; i < response.to.length; i++) {
fb_id = response.to[i];
// Do something with fb_id.
}
}
From looking at the code in the other answer it looks like the facebook API will call back to your page with a query string parameter of ids.
I.e. It will call you site with a url like this.
http://wwww.yoursitesulr.com/mypage.aspx?ids=13,22,44
You can then pull out the id's from the query string using
string myIds = Request.QueryString["ids"];
You can then convert them to a array.
var ids = myIds.Split(',');
If you are using MVC then you can take advantage of the model binders and just put an int array in your view model and it will get bound automatically.
The answer below addresses your specific issie so I would use this as a starting point.
Faceboook: Posting to Multiple Friend's Walls Using Multiple Friend Selector and JS SDK
Let me know if you have any questions regarding the above solution.
Regards
Steve
The problem is that 1) Facebook seems so fluid with how it allows developers to interact with it (FBML, iFrame, different versions of SDKs) and 2) Everything I find is either PHP or Javascript and I have NO experience with those. What I am trying to do seems sooo simple, and I can't believe there isn't an easy way to do this.
What I have:
I used Visual Studio 2010 to create a simple web application (asp.net/C#) that asks the user for some info (first name, last name, email, etc.). I have a button on there called "Submit" that, when clicked, saves the entered data into a database. I have this hosted on GoDaddy (I know, I know...heh) and it works just fine. No problem here.
I created a "Facebook App" that uses the iFrame thingy so that basically I have a new tab on Facebook that displays my web app mentioned above. This works fine too. The tab is there, the web app is there, and users can enter the data and it is saved to the database. No problem here.
What I WANT:
I want the web app (the thing displayed by the facebook app) to only show the data entry part if the user currently "likes" the facebook entity. I DO NOT want to have to ask permission. I just want to know if they are a fan of the company's facebook "page" that has this app. So I need two things here, shown in my pseudo code below:
Part 1 (check if user is already a fan):
If (user is fan)
{
Show data entry area (unhide it)
}
else
{
Show "Click the like button to see more options"
}
Part 2 (listen for "like" event)
WhenLikeButtonPressed()
{
Show data entry area (unhide it)
}
I've seen stuff about "visible to connection", C# sdk, edge.create, etc. but I just can't make heads or tails of it. I don't mind putting in Javascript or PHP if someone could please give me exact, "Fan Gate for Dummies" steps. Please, I'm going crazy over here :-(
The key is is the signed_request that Facebook posts to your app when the user accesses the page. It contains the data on whether or not the user likes the page. You shouldn't need to worry about catching edge events on an actual tab FB page as it get's reloaded when the user likes/unlikes the page.
You'll need to decode the signed request with your app secret to get the like info. There are examples provided for PHP but I'm sure with a little google help you can find decode info for the signed_request for asp.net/c#.
Here's the php decode for reference:
function parse_signed_request($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
// decode the data
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);
if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
error_log('Unknown algorithm. Expected HMAC-SHA256');
return null;
}
// check sig
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if ($sig !== $expected_sig) {
error_log('Bad Signed JSON signature!');
return null;
}
return $data;
}
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
and the link https://developers.facebook.com/docs/authentication/signed_request/ the like info will be contained in the page variable
I created a site where I need to display the images from my facebook album to my personal website but when I call the GetPhotoAlbum().Count method then it returns a '0' count.
Any ideas why it says a zero count as I have 100's of public photos in my facebbok account?
Here is the code:
FriendList1.Friends = _fbService.GetFriends();
works fine and displays a list of all my friends list.
Response.Write(_fbService.GetPhotoAlbums().Count);
returns 0 and no photo/album is displayed
You need to get an access token with "user_photos" extended permission. You can test this with the new Facebook graph explorer.
I'm trying to use the Facebook C# SDK to post to a Facebook page stream, but I'm failing miserably. This is what my code looks like:
var app = new Facebook.FacebookApp(_accessToken);
var parameters = new Dictionary<string, object>
{
{ "message" , promotionInfo.TagLine },
{ "name" , promotionInfo.Title },
{ "description" , promotionInfo.Description },
{ "picture" , promotionInfo.ImageUrl.ToString() },
{ "caption" , promotionInfo.TargetUrl.Host },
{ "link" , promotionInfo.TargetUrl.ToString() },
{ "type" , "link" }
};
var response = app.Post(_targetId + "/feed", parameters);
I've checked and I can see the request in Fiddler go through to Facebook, and I get an ID back - however, when I try and view that ID at http://graph.facebook.com/[parentid]_[postid]
I just get a page with "false" on it, and the post doesn't appear on the Facebook page itself either. If I just enter a random postid that doesn't exist, I get "Some of the aliases you requested do not exist" instead.
The accessToken is authorised to use publish_stream and offline access (generated using this url)
Any ideas what could be going wrong? Thanks
Update I should add, this works fine if I change the _targetId to "me" (ie posting directly to my own profile page)
I found the solution here: Which Facebook permissions allow for posting to a page wall (not profile wall)? which did the trick
This is just an idea, but try it after obtaining the read_stream extended permission.
I know from experience that you can use the ID returned to delete the post, but without read_stream I don't think you can retrieve it (and more interesting stuff like the comments)
To post to a Facebook page, You need to request manage_pages permission.
also you have to use the PAGE access_token not User access_token.