First, please excuse me because i speak english like a french cow!
This is it, i have decided to get off the Facebook Toolkit and start to use the Facebook c# sdk.
I looked at the v4.2.1. Then i read "http://facebooksdk.codeplex.com/Thread/View.aspx?ThreadId=241181" and i downloaded the v5 source code.
I've got a little problem with the auth process with this V5.
Here is my code:
string _requiredAppPermissions = "offline_access,email";
FacebookApp fbApp = new FacebookApp();
var fbSettings = new FacebookSettings();
fbSettings.AppId = RWE.Core.Config.FacebookApp;
fbSettings.AppSecret = RWE.Core.Config.FacebookSecret;
Authorizer authorizer = new Authorizer(fbSettings);
//Authorizer authorizer = new Authorizer();
if (!String.IsNullOrEmpty(_requiredAppPermissions)) authorizer.Perms = _requiredAppPermissions;
authorizer.Perms = _requiredAppPermissions;
authorizer.ReturnUrlPath = _AuthUrlReturn;
authorizer.Authorize();
var me = fbApp.Api("me");
So if i load the app from the url : "http://apps.facebook.com/myapp", it displays a facebook logo with (in french) "Accéder à Facebook" (which means 'access to facebook'). The link is kind of "http://www.facebook.com/connect/uiserver.php?app_id=170580299646394&method=permissions.request&display=page&next=http%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html&response_type=code&fbconnect=1&perms=offline_access%2Cemail"
If i load the app from "http://realurl.com", it displays directly the authorisation form like it should be in the facebookapp url.
My questions are :
How can i have the auth form displayed directly (without the facebook logo step) ?
While i specify a ReturnUrlPath, facebook still uses facebook.com/connect/login_success.html and leads me to facebook.com instead of going back to the app. How can i change that ?
Make sure you specify target="_top" for your <a> tag.
<a href="..." target="_top" />
Related
I have wpf desktop application and I want Facebook login integration in this application so that users can share images from local machine, moreover I am using "Facebook.7.0.6" sdk. Apparently I am facing following issue on login screen.
Given URL is not allowed by the Application configuration: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
And below coding I am using in my application.
private Uri GenerateLoginUrl(string appId, string extendedPermissions)
{
// for .net 3.5
// var parameters = new Dictionary<string,object>
// parameters["client_id"] = appId;
dynamic parameters = new ExpandoObject();
parameters.client_id = appId;
parameters.redirect_uri = "https://www.facebook.com/connect/login_success.html";
// The requested response: an access token (token), an authorization code (code), or both (code token).
parameters.response_type = "token";
// list of additional display modes can be found at http://developers.facebook.com/docs/reference/dialogs/#display
parameters.display = "popup";
// add the 'scope' parameter only if we have extendedPermissions.
if (!string.IsNullOrWhiteSpace(extendedPermissions))
parameters.scope = extendedPermissions;
// generate the login url
var fb = new FacebookClient();
return fb.GetLoginUrl(parameters);
}
void facebookBrowser_Navigated(Object sender,NavigationEventArgs e)
{
var fb = new FacebookClient();
FacebookOAuthResult oauthResult;
if (!fb.TryParseOAuthCallbackUrl(e.Uri, out oauthResult))
return;
if (oauthResult.IsSuccess)
LoginSucceeded(oauthResult);
}
Note : Let me know if Facebook have any change in term and condition for desktop application.
Thanks
After some study I got this link and now my application working fine.
Please set below settings on Facebook app first.
Native or desktop app? - Yes
Client OAuth login - Yes
Embedded browser OAuth Login - Yes
read more from this link :-https://www.hackviking.com/2014/11/facebook-api-login-flow-for-desktop-application/
Thanks
This error means you haven't configured well you app on facebook
If you are testing on localhost, you need to add a platform to your app, then configuring the "site url" for the example http://localhost. Then create a test app (a copy of your main app) and use it for your tests.
I'm doing following code for posting a link to my wall from c# desktop application, but it returns (FacebookApiException - #100) Invalid parameter
FacebookClient fb = new FacebookClient(accessToken);
Dictionary<string, object> postArgs = new Dictionary<string, object>();
postArgs["message"] = comment;
postArgs["link"] = "https://www.google.com/";
fb.Post("https://graph.facebook.com/me/feed", postArgs);
I am having the same issue.
If I change the link to be the link in my Website => site url it works (i.e. the url of the application).
I believe they url in the link, you want to use, can be added to the App Domains section of the basic app settup. I have had mixed results with this.
you must turn off the Stream post URL security option in the dashboard of your app: https://developers.facebook.com/apps , clic on settings and then migrations.
See more information in the Migrations > Stream post URL security bullet : https://developers.facebook.com/docs/facebook-login/security#surfacearea
I got a code which successfully posts to the user's timeline on facebook using the facebook c# sdk. My problem is that I have to post a 400x210 image. The code I have does work but, even If the image filled in the picture argument is a 400x210 dimension image, It appears small and cut at the user's timeline.
Here is the code I'm using:
FacebookClient client = new FacebookClient("xxxxxxx");
var args = new Dictionary<string, object>();
args["message"] = "message text";
args["caption"] = "caption";
args["description"] = "message";
args["name"] = "name";
args["picture"] = "picture of the 400x210 image";
args["link"] = "link url";
client.Post("me/feed/", args);
I've been searching the facebook api docs, here (stackoverflow), and google but I didn't find the answer for this.
Would anyone know what I have to change in my code to make the imagem appear in its full size at the user's timeline?
Thanks in advance
To do this you want to upload the photo to Facebook through the graph api, instead of creating a wall post.
Look here for a php example, and here for the Facebook HowTo
I am using C# winforms and C# Facebook SDK 6 to create an app that control my page and automate somethings.
In all posts in my page i put tags in the text to other pages so i want to know how to post a tag in my page posts using Facebook SDK and Facebook graph API.
I tried the message_tag parameter in different scenarios but it didn't work maybe i am using it wrong, the code below is one of the senarios :
dynamic postParameters = new ExpandoObject();
postParameters.message = textToPostTextBox.Text;
postParameters.message_tags = new { id = "page_to_tag_id", name = "PageName", type = "page", offset = 3, length = 4 };
dynamic result = fb.Post("my_page_id/feed", postParameters);
Notes : a tag to page is when you type "#" and write the page or person name.
Please help me i searched a lot online and i tried my self but it didn't work and sorry for my bad English.
Like said CBroe said, the bug got disabled because of too much abuse , But always there is a way ,
i know someone who did it, and this is how : he wrote a statue on facebook then he intercept the request sent from the browser and modify it to have a tag with customized text, I didn't try it but I know that it works
I know how to post a message, etc. to a Facebook wall, but I want to post a custom HTML and JavaScript Facebook wall, and I want that HTML/JavaScript code to appear so users can use that from Facebook without leaving Facebook, like embedded YouTube videos I have seen this to be possible...
I use this to post to Facebook:
FacebookWebClient client = new FacebookWebClient();
// Post to user's wall
var postparameters = new Dictionary<string, object>();
postparameters["message"] = "Hello world!";
postparameters["name"] = "This is a name";
postparameters["link"] = "http://thisisalink.com;
postparameters["description"] = "This is a description";
var result = client.Post("/me/feed", postparameters);
How do I do this?
Maybe something like
postparameters["html"] = "html or view";
If it is not possible, how do I post SWF content with Flash parameters?
There is no way to post custom HTML or JavaScript code into a Facebook post because of security issues.
But you can still customize a lot of stuff like the link and the image, if you want to add an action link next to "Like, comment".
Find a lot more about publishing a post in Core Concepts › Graph API › Post.
if it is not possible, how do I post SWF content with Flash parameters?
To post an SWF video, you will need to do some work.
First, create a page that the SWF videos lives on where you can specify Open Graph meta tags. Read
more in The Open Graph protocol.
Then you need to create a post with a link to that page with the Open Graph tags. Then use the "link" parameter of the post object to point to the SWF file.