Facebook C# SDK friend invitation - c#

I have a problem with inviting friends to my application. I tried
with Stack Overflow question Application generated apprequests failing in Silverlight, but it works only when the user already has that application. If not, I get an exception:
(OAuthException) (#200) All users in param ids must have accepted TOS.
So I want to inivite a friend directly through the C# SDK in Silverlight application by user ID, not Facebook dialog box. Is it possible to do this? I'm googling for two days...

For requests without a dialog box, your app can only re-invite user ids of people who already use the app, in an attempt to get the user to re-engage with the app. See the app to user section of https://developers.facebook.com/docs/requests/
App to User Requests can be used to re-engage a user in your app and
can only be sent to users that have installed the app. For example,
notifying a user that something has changed since their last visit,
"10 of your friends are now online".
App to User Request are sent via the Graph API, for more information
see the apprequests docs. App to User Requests are only available for
Canvas apps, not websites, as accepting a request will direct the user
to the Canvas Page URL of the app that sent the Request.
As you can see from the error message you received, that it is not permissible to do this to ids that have 1) never authorized your app or 2) someone who authorized your app, and then subsequently removed the app.
Happy Coding.

It is possible to request a dialog from facebook to invite non-app users.
Do have a look at my answer here.
Is facebook user to user request possible with W8/WP8 c# sdk?

Related

C# - Check if user is logged in Facebook

I'm working on a Windows Phone Silverlight app and I want to make a simple login via Facebook(browser). Is there a way to check if the user is logged in Facebook? I redirect the user to Facebook page with this statement:
Launcher.LaunchUriAsync(new Uri("http://www.facebook.com"));
I don't know if you are using the windows SDK for facebook
(https://github.com/Microsoft/winsdkfb) but it is a third party sdk approved by Facebook.
Before using that SDK you should set up the Facebook developer page for your app. (https://developers.facebook.com/docs/apis-and-sdks)
I hope that helps.
Here is a WPF example that uses the WebBrowser class to get a token: Facebook OAuth in WPF & C# Example
Obviously the WPF related things might differ a bit, but it should at least point you to getting the info you need out of the process. As far as checking whether the user is logged in, I pretty much just checked whether the token is valid by making some http request that uses it and seeing whether it was successful (used a REST client for that).
There was a way to directly check token validity via the Facebook APIs but that was deprecated last I checked.

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.

Facebook C# SDK - invite friend to Web SIte

I have a web site and I want to give a opportunity to users to invite their facebook friends to this web site.
I have:
C# Facebook SDK installed to project
Facebook Dev Account with new app
Users at my site use site's auth control (not oAuth). They register on site and can connect their Facebook profile.
The question is next one: How to allow users to invite their friends to web site not using facebook oAuth (just sending user id) with Facebook C# SDK (or without if it's not possible in this way)
UPDATED
I want to do this in next way: user click the button "invite friends" (standart invitation screen of FB), check friend, click invite - finish action :)
Thanks a lot!
I think you should look at the Requests dialog here: http://developers.facebook.com/docs/reference/dialogs/requests/
Only drawback is, that when users accept the request, they'll be shown your Canvas URL - which means this page loads inside the Facebook UI - they're not redirected to you site entirely.
You could use this page to "sell" your website, so they navigate to your site.
Another approach is using the new Send button: http://developers.facebook.com/docs/reference/plugins/send/
This will send a message with a link to your site.
I dont think that is possible. Becuase to access user private data you need to authenticate yourself as well as user with facebook. Facebook provides OAuth for the same !

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.

How do facebook applications work?

Here's a little bit about my situation:
I want to be able to retrieve a list of emails for the friends of a given user.
Here is how I would like the process to go:
A div box pops up with a login (used to log in to their facebook account, not my website's account system - that is separate)
Then once the user has entered their facebook credentials, they will have a button appear.
Send email to all friends.
If they click on this button I would like an email sent out to all of that user's friends.
Questions:
I only want to pull out emails from a user's friends, so...
1) Is it actually a facebook app that I'm creating?
Many of the tutorials talk about facebook apps and how you have to go to facebook and create an app from there and set all of these settings for page redirects and such. I didn't think I wanted it to be an app, all I want is the information.
2) If I do need it to be an app, how is it supposed to interact with my website? Some talk about iframes, or other methods... How am I supposed to know which to use and how I can integrate it into my site?
You have to create app through facebook, but it's only for autorization information.
api key
api secret
And you have to few options for working with facebook API from C#
Facebook Developer Toolkit
.NET Facebook API Client
Facebook.NET
Bemmu is correct = you can't use facebook to get email addresses.
You can send a facebook messages (which usually sends an email to the recipient as well depending on the users preferences).
You'll need to build a facebook app, and get users to allow it to access their profile information (default request). Then you'll be able to sendNotification to receipientID's.
Start with http://wiki.developers.facebook.com/index.php/Notifications.send and look at other references to the Stream API.
Do read the guidelines and agreements - there's rules on how long you can hold onto stream data and what you can use it for.
Let me add to that the PHP API:
http://wiki.developers.facebook.com/index.php/PHP
http://developers.facebook.com/get_started.php
There are no API methods to get anyone's e-mail addresses on Facebook, and neither are there on OpenSocial. This is so that the e-mail addresses do not end up on spam lists. There is a way to send e-mail without getting to know the actual addresses though. If you get the user to accept extended privileges for your app, then you can send e-mail at some reasonable intervals to that specific user.

Categories

Resources