Connect to facebook and working with api - c#

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.

Related

WP7 Facebook SDK - Connecting the user automatically

I'm currently writing a facebook app for windows phone, and there is something I just didn't find how to do.
Since display=touch currently doesn't work on windows phone, I am forced to use display=popup to get a token and the user's agreement for my app.
This popup mode really isn't fit for mobile apps, so I would like the user to be able to check a box saying "I would like the app to remember my login and password and connect me automatically".
However, when I have the user's login and password, I don't know how to use the OAuth API to effectively login the user without him having to click anything. Is there a way to do that ? Or do I have to wait for the user to choose "Remember me" on the Facebook login page ?
I hope that was clear enough.
Facebook doesn't have a (public) API for taking a users email address and password and returning an access token. The closest thing you can do is customize the HTML that gets returned with JavaScript. I have an example of this on my github.

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 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.

How to login to facebook using the Facebook C# SDK

I'd like to post messages to a group wall without asking user for login information -I'd like to do it programmatically, I can use my user/pass if necessary-.
¿Is it possible to do this without showing the user the login screen?
Note: I'm working with Facebook C# SDK (http://facebooksdk.codeplex.com/) under ASP.NET.
Thanks
No you cannot do this. Facebook prevents this sort of behavior to prevent spamming on peoples walls from fake accounts. You will always have to go through the initial login procedure AT LEAST ONCE.
However, if you get an offline access token for someone then you could continue to make posts from them when they are not logged in. Keep in mind that Facebook limits you to 600 posts per minute.

How do I create a .NET Web Service that Posts items to a users Facebook Wall?

I'm currently toying around with the Clarity .NET Facebook API but am finding certain situations with authentication to be kind of limiting. I keep going through the tutorials but always end up hitting a brick wall with what I want to do. Perhaps I just cannot do it?
I want to make a Web Service that takes in the require credentials (APIKey, SecretKey, UsersId (or Session Key?) and whatever else I would need), and then do various tasks: Post to users wall, add events etc.
The problem I am having is this: The current documentation, examples and support provide a way to do this within the context of a Web site. Within this context, the required "connect" popup can be initiated and allow the user to authenticate and and connect the application. From that point on the Web can go on with its business to do what it needs to do.
If I close the browser and come back to the page, I have to push the connect button again. Except this time, since I was already logged into facebook, I don't have to go through the whole connection process.
But still ... How do applications like Tweetdeck get around this? They seemingly have you connect once, when you install their application, and you don't have to do it again. I would assume that this same idea would have to applied towards making a web service because: You don't know what context the user is in when making the Web service call. The web service methods being called could be coming from a Windows Form app, or code behind in a workflow.
I would advise you to try Steve's blog and starter kit
you can also find a reference to his post in this so question
Good luck
Edited/Added below
You cannot store the facebook login credentials for users and pass them to FB.
(terms & conditions)
but you can use: offline_access, to access some usage without flagging the user as logged in.
Cool tip from this forum:
Use the following URL with your API Key
http://www.facebook.com/login.php?api_key=YOURAPIKEY&connect_display=popup&v=1.0&next=http://www.facebook.com/connect/login_success.html&cancel_url=http://www.facebook.com/connect/login_failure.html&fbconnect=true&return_session=true&req_perms=offline_access
Register for the Facebook Developer
App on your facebook profile.
Create a new app Web App(By default)
through your "Facebook Developer
App". Change the Application Type to
"Desktop App". Note down the API Key
& Secret Key for you app.
Authorize the app & authenticate the user and
then get the permanent session_key.
Authentication
For a fully logged in session, you are asked to use (again terms and conditions) login.php and you can login via JavaScript
HTH
Ric

Categories

Resources