I am trying to implement user registration on my mvc3 site using fb. My question is regard this bit of code
FacebookClient fbClient = new FacebookClient(accessToken);
dynamic me = fbClient.Get("me?fields=id,name");
What other parameters can be specified in the request "me?fields=id,name,??". My application requires Email Address, phone number, address and name (first name, last name). I would be grateful if someone could tell me or better yet point to to somewhere I can find documentation on this.
This is a sample of the parameters you get inside dynamic me = fb.Get("me") without user permission:
"id":"894555532"
"name":"John Doe"
"first_name":"John"
"last_name":"Doe"
"link":"http://www.facebook.com/johndoe"
"username":"john"
"bio":"Sample bio"
"quotes":"\"Sample quote""
"work":[{"employer":{"id":"39233323343","name":"Sample Company"}
"position":{"id":"142461033332450","name":"Backend Developer"}
"projects":[{"id":"214103971985333"
"name":"Coors Light, Sample Project"}]}]
"favorite_teams":[{"id":"171522852874952","name":"Juventus"},{"id":"112325268793829","name":"Barcelona F.C."}]
"favorite_athletes":[{"id":"326971266226","name":"Alessandro Del Piero"}]
"gender":"male"
"timezone":-6
"locale":"en_US"
"verified":true
"updated_time""2012-01-24T09:12:17+0000"}
"email" requires user permission
I'm sure there are other things you can get, though there is no official list for c# sdk yet.
This is a sample of how to get all that info:
var fb = new FacebookWebClient();
dynamic me = fb.Get("me");
imgProfilePic.ImageUrl = string.Format("https://graph.facebook.com/{0}/picture", me.id);
lblName.Text = me.name;
lblFirstName.Text = me.first_name;
lblLastName.Text = me.last_name;
Here's an updated / complete list a scopes for Facebook C# SDK:
ads_management
create_event
create_note
email
export_stream
friends_about_me
friends_activities
friends_birthday
friends_checkins
friends_education_history
friends_events
friends_games_activity
friends_groups
friends_hometown
friends_interests
friends_likes
friends_location
friends_location_posts
friends_notes
friends_online_presence
friends_photo_video_tags
friends_photos
friends_questions
friends_relationship_details
friends_relationships
friends_religion_politics
friends_status
friends_subscriptions
friends_videos
friends_website
friends_work_history
manage_friendlists
manage_notifications
manage_pages
offline_access
photo_upload
publish_actions
publish_checkins
publish_stream
read_friendlists
read_insights
read_mailbox
read_requests
read_stream
rsvp_event
share_item
sms
status_update
user_about_me
user_activities
user_birthday
user_checkins
user_education_history
user_events
user_games_activity
user_groups
user_hometown
user_interests
user_likes
user_location
user_location_posts
user_notes
user_online_presence
user_photo_video_tags
user_photos
user_questions
user_relationship_details
user_relationships
user_religion_politics
user_status
user_subscriptions
user_videos
user_website
user_work_history
video_upload xmpp_login
Related
Although I have full authority, error is error authority:
(OAuthException - #200) (#200) Requires either publish_to_groups permission and app being installed in the group, or manage_pages and publish_pages as an admin with sufficient administrative permission
Facebook Developer below is my display image and
screenshot of my code.
App ID 10525 : makineadresi
Type: User
App-Scoped User ID
Learn More
10214 : Makine Adresi
User last installed this app via: API N/A
Issued: 159756 (about a week ago)
Expires: Never
Data Access Expires: Never
Valid: True
Origin: Unknown
Scopes: user_events, email, manage_pages, pages_manage_cta, pages_manage_instant_articles, pages_show_list, publish_pages, business_management, publish_to_groups, groups_access_member_info, public_profile
string FBPub_ClientId = "4714088892553";
string FBPub_ClientSecret = "80749ba484de42952e928677";
dynamic FacebookPost = new ExpandoObject();
FacebookPost.link = "http://makineadresi.com/tr/80-LiK-Alman-Borwerk-1215";
FacebookPost.caption = "header";
FacebookPost.message = "sub information";
try
{
FacebookClient appp = new FacebookClient("EAABcHPvQGZBUBAA1E3gxwHpp2Ap0uBTXwZAa7ZAalHl3gf0xBhOpVHCzwZDZD");
appp.AppId = FBPub_ClientId;
appp.AppSecret = FBPub_ClientSecret;
var postId = appp.Post("/13289/feed", FacebookPost);
return postId[0];
}
Could you please help ?
All my links in my code are correct. The explanations are modified shapes.
Access Token which is incorrect. The following steps of Access Token can be accessed correctly.
https://developers.facebook.com/tools/explorer/ click url.
where( me?fields=id,name) is written (me/accounts) in summer.
Use the access token located under the data.
I'm developing a new update for my existing Windows 8.1 app (written in C#). On this update, I would like the users to connect to Facebook. I found a lot of tutorials to make this work but I still don't have a solution.
When the WebAuthenticationBroken is called I have the Facebook login page (with Facebook logo and email and password fields) but on the top I have this:
Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. must match the Website URL or Canvas URL, or the domain must be a of one of the App's domains.
When I fill my info and click on Login I got an error like this from the WebAuthenticatonBroken UI: (I'm not using my Windows in English, so I don't know how it is exactly written)
We couldn't connect to the service right now. Check your internet connection or try again later.
My Facebook app is live, the SID is defined on the Windows Store ID field on basic settings.
Here I have my C# code used to call the WebAuthenticationBroker on my Windows 8.1 app:
public Uri _callbackUri = WebAuthenticationBroker.GetCurrentApplicationCallbackUri();
public string FacebookAppId = "15911339xxxxxxxx";
public string FacebookPermissions = "public_profile,email,user_friends";
FacebookClient _fb = new FacebookClient();
var loginUrl = _fb.GetLoginUrl(new
{
client_id = FacebookAppId,
redirect_uri = _callbackUri.AbsoluteUri,
scope = FacebookPermissions,
display = "popup",
response_type = "token"
});
WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(
WebAuthenticationOptions.None,
loginUrl);
if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
{
var callbackUri = new Uri(WebAuthenticationResult.ResponseData.ToString());
var facebookOAuthResult = _fb.ParseOAuthCallbackUrl(callbackUri);
FacebookClient fbclient = new FacebookClient(facebookOAuthResult.AccessToken);
dynamic result = await fbclient.GetTaskAsync("me");
string id = result.id;
string email = result.email;
string FBName = result.name;
ApplicationData.Current.RoamingSettings.Values["UserID"] = id;
var accessToken = facebookOAuthResult.AccessToken;
}
I've already tried with no Valid OAuth redirect uri and with the "https://www.facebook.com" as well, but it's still not working.
I've also tried setting the "Embedded browser OAuth Login" and the "Native or desktop app?" on.
I'm using the most recent Facebook SDK for Windows Store.
I hope someone can help me fix this error.
PS: sorry for my bad English...
Thanks,
Rafael Pedro da Silva
Ok, I got it :) It's working now.
I just had to set the redrect url ( "FacebookClient().GetLoginUrl()" and on the callbackUri of the WebAuthenticationBroker ) and on Facebook settings to "https://www.facebook.com/connect/login_success.html".
First thing first, I never used SDK before and I don't know what does token mean. I am searching for the most simple solution, if possible without SDK, without token, without FB App.
I have a button in my C# application and when the user clicks on it I want a popup window where the user can login to Facebook or if he is logged in he can push the share button in order to share the predefined content.
While searching on the internet I found this code:
var client = new FacebookClient("my_access_token");
dynamic parameters = new ExpandoObject();
parameters.message = "Check out this funny article";
parameters.link = "http://www.example.com/article.html";
parameters.picture = "http://www.example.com/article-thumbnail.jpg";
parameters.name = "Article Title";
parameters.caption = "Caption for the link";
parameters.description = "Longer description of the link";
parameters.actions = new {
name = "View on Zombo",
link = "http://www.zombo.com",
};
parameters.privacy = new {
value = "ALL_FRIENDS",
};
parameters.targeting = new {
countries = "US",
regions = "6,53",
locales = "6",
};
dynamic result = client.Post("me/feed", parameters);
But this example uses Facebook SDK and it needs token. I want a simple solution, without SDK, without FB APP. I want a simple popup with predefined text.
Is there any solution?
An access token is an opaque string that identifies a user, app, or page and can be used by the app to make graph API calls.
Access Tokens identifies an app ,user or page
Without creating an app from facebook and getting a token you cannot proceed in this case(c# application).
I have a website made with ASP.NET webform .NET 4.5 C#. This site contains a forum(homemade by me), parts of this forum needs to be posted to the specific facebook wall(made for this webpage). What I need :
Post just created thread(message) from specific part of the forum to the corsponding facebook wall.
Optional : Sync the forum thread on webpage with message/comments on the specific facebook page
I have looked at these guides :
http://www.codeproject.com/Articles/569920/Publish-a-post-on-Facebook-wall-using-Graph-API
http://www.c-sharpcorner.com/UploadFile/raj1979/post-on-facebook-users-wall-using-Asp-Net-C-Sharp/
But im not sure that this is really the solution for me? I have tried to follow the guide but it does not look the same.
Edit :
dynamic result;
//https://developers.facebook.com/tools/explorer/
//https://developers.facebook.com/tools/access_token/
FacebookClient client = new FacebookClient(ConfigurationManager.AppSettings["FacebookAppToken"]);
//result = client.Get("debug_token", new
//{
// input_token = ConfigurationManager.AppSettings["FacebookAppToken"],
// access_token = ConfigurationManager.AppSettings["FacebookAppToken"]
//});
//result = client.Get("oauth/access_token", new
// {
// client_id = ConfigurationManager.AppSettings["FacebookAppId"],
// client_secret = ConfigurationManager.AppSettings["FacebookAppSecret"],
// grant_type = "client_credentials",
// //redirect_uri = "http://www.MyDomain.net/",
// //code = ""
// });
result = client.Get("oauth/access_token", new
{
client_id = ConfigurationManager.AppSettings["FacebookAppId"],
client_secret = ConfigurationManager.AppSettings["FacebookAppSecret"],
grant_type = "client_credentials"
});
client.AccessToken = result.access_token;
result = client.Post("[IdOfFacebookPage]/feed", new { message = "Test Message from app" });
//result.id;
result = client.Get("[IdOfFacebookPage]");
return false;
Approach to post to a facebook wall:
You need to register in facebook developer tools.
Create a app (fill a form).
Download FGT 5.0.480 (Facebook graph toolkit)
Reference FGT dlls in your web application.
FGT has methods to post to facebook wall but needs appId.
Use the app id of your app created in step 2.
To post to an user's wall through facebook, it is only possible through an app.
Try this asp .net app, which will allow you to post in your wall:
https://apps.facebook.com/aspdotnetsample/?fb_source=search&ref=br_tf
This will allow you to envision what you need.
Your app gets an appId with which you need to generate auth token.
Limitation: The user's wall where you want to post should have added the app created at step 2, this is compulsory and there is no work around.
When the user accesses the app for the first time, it automatically asks for permission to post to wall--> the user needs to accept it.
Hope this gives you an idea on how to go about doing this.
You can then post into the user's wall.
For Banshee's below request using Facebook SDK for .NET:
userId - facebook user id, wall to post the message
This user should have added the app created by you in step 1 else it will say unauthorized access.
dynamic messagePost = new ExpandoObject();
messagePost.picture = "http://www.stackoverflow.com/test.png";
messagePost.link = "http://www.stackoverflow.com";
messagePost.name = "This is a test name";
messagePost.caption = "CAPTION 1";
messagePost.description = "Test desc";
messagePost.message = "message"
var fb = new FacebookClient();
dynamic result = fb.Get("oauth/access_token", new {
client_id = "app_id",
client_secret = "app_secret",
grant_type = "client_credentials"
});
fb.AccessToken = result.access_token;
try
{
var postId = fb.Post(userId + "/feed", messagePost);
}
catch (FacebookOAuthException ex)
{
//handle oauth exception
}
catch (FacebookApiException ex)
{
//handle facebook exception
}
You will need an extended token to publish to a wall.. Steps to get extended token is explained well by Banshee..
Edit: How to get extended token by Banshee:
Please follow this post
By creating a extended page token and use it to make the post everything works just fine. See this : How to get Page Access Token by code?
Im surprised that this simple task was so hard to get running and that there was vary little help to get.
I'm driving myself to despair trying to get an album added to a facebook page using the C# SDK..
I think my code is OK as I can successfully create an album on my own profile page through the SDK and API. So, I expect something's getting confused with my access tokens and permissions etc.
My c# code is here:
string accessToken = "TOKEN HERE";
FacebookClient facebookClient = new FacebookClient(accessToken);
var albumParameters = new Dictionary<string, object>();
albumParameters["message"] = "new message";
albumParameters["name"] = "new name";
facebookClient.Post("/412639422128107/albums", albumParameters);
The error Im getting is:
(OAuthException - #1) An unknown error has occurred.
I've read loads of posts on here and elsewhere on the web about getting the page's access token. Which I'm pretty sure I'm doing right -
I go to this page: https://developers.facebook.com/tools/explorer
I type in "me/accounts"
I see a couple of pages i'm the admin of, and grab the access token that corresponds with my page id that i'm trying to add the album to (412639422128107)
I check the permissions on this access token by going here:
https://developers.facebook.com/tools/debug/access_token?q=
I see that I've got the following permissions: create_event, create_note, manage_pages, photo_upload, publish_actions, publish_stream, read_stream, share_item, status_update, video_upload
But, I'm clearly not doing something quite right as it's not working! Please could anyone point me in the right direction?
Thanks loads in advance :)
you can create an album in the facebook page with this code.
string accessToken = "";
FacebookWebClient fbApp = new FacebookWebClient();
dynamic parametersForToken = new ExpandoObject();
parametersForToken.fields = "access_token";
try
{
dynamic me = fbApp.Get(idExternalPage, parametersForToken);
accessToken = me.access_token;
}
catch (Exception ex)
{
return;
}
FacebookClient facebookClient = new FacebookClient(accessToken);
var albumParameters = new Dictionary<string, object>();
albumParameters["message"] = "new message";
albumParameters["name"] = "new name";
facebookClient.Post("/me/albums", albumParameters);
or try this
https://developers.facebook.com/tools/explorer?method=GET&path='Page_Id'%3Ffields%3Daccess_token
Sorry i'm testing my script, and i have the same problem. (only for creating gallery)
see this bug: https://developers.facebook.com/bugs/376442565760536?browse=search_50361119879b15494037772 (the bug is fixed)