Facebook get user id - facebook

I am making a simple contest on Facebook which is a form to fill in.
I would like to add a mechanism with share options.
You will win another chance for each friend who will click on the back link.
Technically i wish to add to the shared url the user id to add 1 chance for him in my database (sharing options will appear after the form)
So i need the user id but i don't want to display the FB popup "accept this application" before launching my app. Is it possible?
If not, do you have an id or online to do it with open graph and all that stuff?

There is no way to get the User-/Facebook-ID of the user without login/authorization. The signed request variable only presents basic infos if the user is not logged in (like status, admin status, locale, ...).
So, in order to get the User ID you have to authorize the user, i recommend the JavaScript SDK for this:
https://developers.facebook.com/docs/howtos/login/getting-started/

This is against the Facebook Page Terms.
You can not have a contest where sharing is considered a entry in a contest.
Follow this link and look at Section III.E.3 for details
https://www.facebook.com/page_guidelines.php

Related

Tracking user activities on facebook

I've created a Facebook page and implemented an application for it too. Now, my aim is that, a user must like and share page with at least one friend to be able to participate/to get access to the app and consequently use it (play the game). Or simply force a user to like and share the page. Can you please tell me if this is even possible and how it can be achieved?
When user visits your Facebook page, you receive signed_request , which contains some information about the user, including whether or not the user liked your page. For share, you will probably need to implement send dialog. In documentation it is said that user takes action (send or cancel) he will be redirected to url you set up, and if the action was "cancel", there will be an error.
So you will probably need to create db where you store user id and whether or not he shared your page before (since you can check if he liked the page at any time).

After facebook login, retrieve facebook address of user?

I am trying to utilize facebook login for my website's alumni tracer. What I want to do now is to be able to retrieve the facebook profile address of a user, how can I do that? What I am planning to do is to list down all the names with a link such that when the link is clicked then it will go to the users profile.
TIA
You can always just link to www.facebook.com/{userid}.
Or you could first check if the user has a username set [1], and then just link to www.facebook.com/{username} – if you want the links to look “prettier”. www.facebook.com/zuck maybe looks a little nicer then www.facebook.com/4 – but the numeric id link will always automatically redirect to the version with the user name anyway.
[1] AFAIK everyone has a username set nowadays – if the user did not set one explicitly themself, Facebook makes one up out of their first name/last name compination.

Starting with facebook app (need guidelines)

i'm trying to make a facebook app, to make draws (like raffles) between the users who like my fan page, or eventually who likes a post.
I've been developing another app which do other stuff, but i'm stuck with this and it's really frustrating to not be able to do something so simple as this.
In the first place, i wish to make it available in a page tab (and that users doesn't need to "install" the app. Maybe this isn't needed if the user is just "looking" at a page that is loaded in my hosting)
Second, i don't know how could i get (assuming the one who enters the app/page tab is an admin) all the users who liked the page/post without using an access_token (because this damn access_token has an expiration time, and if i could, i'd try not to use an access token at all, since i assume the user who gets in into some parts is an admin
Any ideas?
You can't make an app that draws a contest winner from the people who like your page. Facebook does not allow you to query the fans of your pages anymore.
You can still query the users who like a post on your page though so you should set your contest up this way.
To get started, you'll need to create a connector app for your page. Users don't need to register for this app. As long as they like your page, your app will be able to access their public data. Your app will have an API key and secret. Using these, you'll be able to access information about your page.
To find a user who liked a post, you can query this with a variety of languages. I'm not sure which one you are using, so I'll give you instructions to do this from the Graph API Explorer: https://developers.facebook.com/tools/explorer
Make your post on a page, and type PAGE_ID_OR_USERNAME/feed where you replace PAGE_ID_OR_USERNAME with your page's id or username. Find the id of the post you just listed in there. It will look something like this: 213365490637345_40261112079719 (not a real post_id)
Now you can get all the user ids of people who liked that post by typing this into the explorer box:
fql?q=SELECT user_id FROM like WHERE post_id = "213365490637345_40261112079719"
And then choose a random id from that list and contact that particular user. You may have to use Facebook as your page when you try to contact them.

What type of application to choose

I want to create facebook application that will allow to insert some data from my site to user's profile. User can choose to set up application. The users enters his ID on my site and when user's profile is viewed there is block of data loaded from my site (specified to the ID).
Is this possible to create such application with facebook ? If no the what type of application is closest to this? My site users want to display their profiles from my site inside their facebook profiles , so facebook friends can see this.
If I understand you correctly you want to add some additional data on the users Facebook profile, something like if Stackoverflow would add their flair on the Facebook profile.
I don't think this is possible, but you have a few alternatives:
Make the user post out a link to his profile on your site to his Facebook Wall, more details here.
Integrate your site to the new Open Graph Objects. Open Graph Objects will create a box on the users profile for your application which shows the users activity in your application. You should check out the demos and documentation for more information about this.
The users enters his ID on my site and when user's profile is viewed there is block of data loaded from my site
You can't do anything like this, you will need to use the authentication flow provided by Facebook in order to get access to the Facebook user data and then tie up the Facebook user to "your user", see documentation.
When it comes to what type of app you should create, there is basically only one type of app with some different options. But you should focus on the "Facebook for websites" documentation.

Information about user how liked my page/group

After a user clicked on a "like" button of a facebook group or facebook page is it possible to get any addional information about the user beside name and uid?
I know with an app I can request access to a lot of data but I don't want to do that. I also know about facebook statistics.
The question targets more at the point if I publish any information about me if I like something.
The user ID isn't included in the callback on the edge.create event when a user clicks like, so the page doesn't get it then.
If you get a user ID via the user authorising your app you can access their public information at https://graph.facebook.com/ but you'll need them to allow additional permissions to see anything which wouldn't be accessible to a logged-out user.