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.
Related
I am trying to get the total photo count of a user.
I tried these
me?fields=photos.limit(200).fields(images)
this returns id,not photo count
me/albums?fields=photos
me/albums?fields=photos?fields=source,name,id
me/albums?fields=photos&fields=source,name,id
gives cover photo ,profile photo
me?fields=albums.fields(id,name,cover_photo,photos.fields
on Graph API explorer with required permissions but either they are giving unnecessary info or the API returns an error.
You need the count field for each album
me/albums?fields=count,name
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
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...
I have some doubts:
I want to show the photos from my company facebook page on my company web site using C# SDK.
How can I do that with an access token which never expires? Or why my app id and app secret is not enough?
var fb = new FacebookWebClient("app_id", "app_secret");
If I only use this it says:
An active access token must be used to query information about the current user.
Basically I see non-sense to ask for a valid access token because it's not about to interact with any of my visitors' page but just simply show my photos from my company facebook page to them.
UPDATE: To get my app token I am doing:
var oauthClient = new FacebookOAuthClient
{
AppId = "app_id",
AppSecret = "app_secret"
};
dynamic result = oauthClient.GetApplicationAccessToken();
accessToken = result.access_token;
But now, how I can show photos from my account?
If I do it like:
var fb = new FacebookWebClient(accessToken);
//Get the album data
dynamic albums = fb.Get("app_id/albums");
I receive an empty JSON but I am sure that my account on facebook has several albums.
Tokens can and do expire. You must have code in place to handle when it does.
Your appid and app secret are not enough because at least one of the page admins MUST grant access to the page to get photo data via the Graph API.
Remember, the API is not only Facebook's sandbox, but they also are the ones who built it, so you're going to have to play by their rules.