Logging out of Facebook with WebAuthenticationBroker - c#

I'm building a Windows Store 8.1 application in C#. It's a photo booth application, so many different people are going to be walking up to a single device and getting their pictures taken.
One of the features of the application is the ability to share your photo on social media sites. I was able to implement a Facebook login using WebAuthenticationBroker. However, what I need to do next is post their photo and then log out of Facebook. The last thing I want is for somebody else coming up to the photo booth with a different person's cached credentials.
I could use any advice on how to proceed here. Below is the code I used to log in:
WebAuthenticationResult authenticationResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, new Uri("https://www.facebook.com/dialog/oauth?client_id=MyAppId&response_type=token&scope=publish_actions&redirect_uri=" + WebAuthenticationBroker.GetCurrentApplicationCallbackUri()));
Through great pains I was also able to capture what the Facebook logout URL should look like:
https://www.facebook.com/logout.php?access_token=MyAccessToken&next=https%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html
Has anybody figured this one out yet?

What is your exact question? How to post photos to Facebook?
Although there is no official C# SDK by Facebook, the following might be the easiest to use: http://facebooksdk.net/docs/windows/
Otherwise, you can implement raw API calls and POST to {user_id}/photos, as described here: https://developers.facebook.com/docs/graph-api/reference/user/photos/#Creating
When you app is live, you also need to submit for review and request the publish_actions and user_photos permissisons.

Related

Scheduling Facebook posts for future

I am developing an application by which we can schedule our posts for future & which will be automatically posted to facebook on scheduled time.
I am able to post when I am logged in to facebook using my web application but I have no idea how will i post on scheduled time when i am not logged in to the facebook.
How will facebook identify that post should be posted on my wall & not on others wall.
Can any one help me.
I am using c#, asp.net for my application.
You create a facebook application using the Facebook API, you will then add that application your account providing it with the ability to post to your wall.
Then simply have the application check a database with your pre written content in, and when it's time post the content.
Have a look at the getting started guide: http://developers.facebook.com/docs/
If more than one person is using the application then there will a public token saved in the database assigned to each user, which facebook will authenticate against to see if that token/app has permission to post to that particular users wall.

Getting my own data from facebook using C# WITHOUT an application

I've been googling for a couple of days, and I could not find any clue how to achieve that:
I have a desktop application(C#) in which I'd like to be able to login to my facebook profile, and pull some data from it(e.g. profile information, wall posts, likes on my posts, etc.)
Note that I DO NOT want to develop a facebook application, I simply would like to access my own user data.
As far as I see, the Graph API was designed to develop FB apps, and Graph API calls always need an access token, but I do not have token, since I do not use any Facebook application.
By now, the only way I see for that is to add a web browser component to my application, and login to the facebook through it, but it's quite inconvenient to process the pure HTML, and, since the HTML itself can change at any time, the maintenance of the application would be a horror.
So I'd like to find some way to pull data from facebook in JSON format, like the Graph API, but without having a Facebook application.
Thanks in advance for the answers.
It's not possible to access the data without a facebook application.
As you wrote, you need an access token for most graph requests, and in order to have an access token you need an application.
More than that, from what you wrote you'll need extra permissions which are not granted by default (for the user photos, wall posts, likes and so on).
Facebook can't just give you the info you see, the user has to grant a specific application the right to access their data, and because of that you must have a facebook app.
I don't see what the problem is though, just create a facebook app, it's not that complicated.

Facebook API allowing deauthorization of application

I know this question has been asked in the past, but times have changed and I am hoping the facebook SDK has progressed. I have seen other websites with the ability to deauthorize their app from the website rather than having the user sign in to facebook to do it. An example is glassdoor.com. If you create an account and then sync your FB account you can then deauthorize on the Account page. Any ideas on how this works because I have searched facebook docs and find only the deauthorization callback.
In graph API you can issue an HTTP DELETE request to /UID/permissions to revoke authorization for an app. Or you can use auth.revokeAuthorization from legacy REST API.
https://developers.facebook.com/docs/reference/rest/auth.revokeAuthorization/
hope this helps

Facebook website integration - what's actually possible in terms of custom website features

I know there are a lot of questions out there for facebook integration, and a lot can be read of off developers.facebook.com - which I did. But I'm missing some clear and precise answers as to what I can actually do in terms of my project.
So I know I can connect my website with a facebook account, and as far as I can read it's possible to "attach" a facebook account to a user in my own custom user-database. Correct?
I'm looking primarily to be able to do this, but not necessarily require the user to have a facebook account to use my app. And as far as I've understood, this is possible too.
To provide context I'm building a specialized photo sharing app.
Where it gets iffy for me, is if I choose to have the ability to comment on a picture on my app. I know there is the social plugin "Comments" for facebook, but how exactly would this work? It would store the comments in facebook would it not? And if a user with no facebook account registers at my site, he won't be able to use the comment feature? Can he even see the comments? Is it at all possible 'hook up' facebook comments to a custom comment-feature on my site? So the user without facebook can still comment?
And this whole integration - would it require the user to 'install' a facebook app (mine) on facebook?
"So I know I can connect my website with a facebook account, and as far as I can read it's possible to "attach" a facebook account to a user in my own custom user-database. Correct?"
Correct, you use the userid that Facebook provides to identify the user.
"I'm looking primarily to be able to do this, but not necessarily require the user to have a facebook account to use my app. And as far as I've understood, this is possible too."
Yes, you just need to built the extra functionality into your app (allow for registrations coming from FB or a regular form from your website). You might want to have a look at Facebook's registration plugin.
"The plugin also allows users who do not have a Facebook account, or do not wish to sign up for your site using Facebook to use the same form as those who are connecting with Facebook. This eliminates the need to provide two separate login experiences."
"I know there is the social plugin "Comments" for facebook, but how exactly would this work? It would store the comments in facebook would it not?"
Yes, it stores them on FB, but you can access them and replicate them into your database via the Graph API. Read this for details.
"And if a user with no facebook account registers at my site, he won't be able to use the comment feature? Can he even see the comments? Is it at all possible 'hook up' facebook comments to a custom comment-feature on my site? So the user without facebook can still comment?"
The comments feature will not be tied to your site's registration, since it does a separate auth check. Unfortunately, the comment plugin does not support anonymous comments, or pushing comments into it from another app, so a user will have to have an account in Facebook, Yahoo, AOL or Hotmail to post a comment. But all users will be able to see the comments, regardless of account status (you can control that from your code of course - e.g. hide the comment plugin for a user group).
Besides FB's plugin you can have a look at other solutions like Disqus (http://disqus.com/), which supports multiple login sources AND allows for anonymous comments if you want.

Connect to facebook and working with api

Is there any good tutorial how to make simple console facebook appplication which connect to facebook and get list of friends, user photos, status or something. I look at facebook examples of facebook SDK but if i want to authorize on facebook i must execute FacebookService.ConnectToFacebook method which show login window. But i want show my own login window. Or just store login and password in sql server and time to time get some information about users. Is it real?
Check out the tutorial and examples here.
It should have all the functions that you need and is fairly easy to implement. Trust me, you'll spend hours going elsewhere to figure it out.
As for custom login windows I recommend that you don't do that. People trust Facebook and don't want to give you their personal info, that's actually a part of your agreement with Facebook.
What you can do however is ask for offline access permission and store the token for future use. This way if you know who the user is on your end then you can make calls to the API without having to log them into Facebook again.
Facebook requires that users login with them and Facebook will send you back a token which you can use. This is prevent applications "stealing" usernames & passwords, which you could do with your login dialog and also allows users to stop applications in future from accessing their account even if they have logged in previously.
No way round that unfortunately, unless you going to build something that doesn't use the API - for example, a tool which loads a browser in a background, and automates the login as if the user did it. That would lead to pain and suffering though.

Categories

Resources