How do I generate Facebook like button with only the FB page ID - facebook

So I have a database table with the Facebook page ID's of my users. I would like to generate a like button dynamically with only the ID available to me to do this. The problem as I see it is that I don't know what the data-href attribute is supposed to have considering that Facebook page url's look like this: http://facebook.com/pages/hyphenated-name/<?=$FB_id?> and I don't have the hyphenated name stored in my database to generate the that url.
Is there another URL structure Facebook's back-end will accept that just has the ID and not the hyphenated name, but will still count likes on that person's Facebook fan page? Is this impossible?

You can do a look up of the id, and retrieve the link of the page stored.
example: https://developers.facebook.com/tools/explorer?method=GET&path=191825050853209
refer to: https://developers.facebook.com/docs/reference/api/page/ under link connection.
This method will require use of the graph api, or one of the sdks.
refer to: https://developers.facebook.com/docs/reference/api

Related

logging referrer ID with Facebook page like

Is there any way to log the referrer Id for a Facebook page like action.
Use Case:
I have a site with FB like plugin integrated in few modules, which are referencing to a FB page.
I want to log a particular Id (specific to particular module) when user Likes the page, so that I can analyze later which module generated how many likes.
I can find 'ref' option in FB API: https://developers.facebook.com/docs/plugins/like-button#faqref
But not sure whether it will fit in my scenarios and how.
When you use the ref parameter on a like button, clicks back to your website which were generated by that Like button, contain two extra parameters in the referrer: fb_ref, containing the same value you gave to ref, and fb_source which shows where on Facebook the story was clicked.
BTW, this answer has been previously answered here: Tracking like button referrals from Facebook using the 'fb_ref' parameter in our code
Here's some relevant documentation from the Like Button and the Ref Param:
https://developers.facebook.com/docs/plugins/like-button
https://developers.facebook.com/docs/plugins/faqs/#ref

How to get the facebook user id that likes my website (not a facebook site)

I am making a raffle within the people that had make an "I like" to a certain article of my external website (non facebook). In order to choose the winner I need to know who has made the I like.
This query:
https://api.facebook.com/method/fql.query?query=select%20like_count%20from%20link_stat%20where%20url='myWEBSITE'&format=json
Only get me the total count of I Likes but not the users ID
This query is perfect:
https://api.facebook.com/method/fql.query?query=SELECT%20user_id%20FROM%20like%20WHERE%20object_id%3D%MY_object_ID&access_token=MY_ACCESS_TOKEN
But how do I get an OBJECTID for an external url??
Thanks in advance
Object can be any thing like video, note, link, photo, or album but can not be any FB page or Url.. So I guess its not possible to get the user Id for a URL.
If you are using JS SDK / Like plugin in your website to like it, i think you can subscribe to an event and then use some ajax calls to get those userIds whenever they instantly like it.
See Somnath Muluk's answer in https://stackoverflow.com/a/13467793/269521

What is the difference between a Facebook Page "Like" and an external URL "Like"? And will the "user_likes" permission scope give access to both?

I'd like to pull a list of all Facebook "Likes" for a user, whether they are Facebook pages or external URLs.
Example:
If you "Like" the Facebook Platform, I know I can see it via the /me/likes API call.
However, if you like an external URL, I'm not sure how to pull that. Are both supposed to be pulled via the /me/likes call? Or is there another call to handle external likes?
Further, what about newsfeed / stream likes? For example, if I "Like" a photo, video, status or link that I see in my stream, is that accessible via the API? If so, how is this accessed?
Yes, user_likes will give you access to both.
You can access external likes as you wish through the Graph API endpoint /me/likes, as long as they're not articles. Objects with type "article" do not represent real-world objects and as such, we don't provide on a person's profile. We mention this (albeit obscurely) on the Open Graph documentation page: https://developers.facebook.com/docs/opengraph/#types
So if you go to my fake movie object page at
http://fbsb.hoodlu.ms/so_7436857/video2.html
and click like, that will show up when you access your likes on https://graph.facebook.com/me/likes.
Try it using the Graph API explorer:
https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Flikes
If you want the URLs that someone has liked, use this FQL query:
SELECT url FROM url_like WHERE user_id = me()
More information is available at https://developers.facebook.com/docs/reference/fql/url_like/.
If you want to access the likes from a post, photo, video, etc. you'll need to use the like and stream FQL tables. To just pull out the likes (of posts/photos/videos) for the current user:
SELECT user_id, object_id, post_id FROM like WHERE user_id=me()
From there, you would query the stream table for the post to get more information.
like table documentation: https://developers.facebook.com/docs/reference/fql/like/.
stream table documentation: https://developers.facebook.com/docs/reference/fql/stream/
Facebook now has two ways to read likes. If you would like to get the likes of an external URL you try this:
http://graph.facebook.com/me/og.likes/[ID_FACEBOOKOBJECT]
And if you wish get the likes from an internal Facebook page (fan page,profile,photo like) try this:
http://graph.facebook.com/me/likes/[ID_FACEBOOKOBJECT]
Checkout: https://developers.facebook.com/tools/explorer

facebook and opengraph (ap id question)

I am integrating a like button into one pf my pages, using the information here.
I want to use Open Graph Tags, but that requires supply of fb:admins or fb:app_id tag elements. The thing is that I cannot find any information on how to obtain these IDs.
The Id is that likes on the webpage appea on the wall of the facebook page (Note: NOT a user profile). Does anyone know which ID to use, and where to get the ID from?
You can get your own user id to put into the fb:admins field by logging into facebook and then going to this url:
https://graph.facebook.com/me/?access_token=2227470867|2.AQCPDqXNTW9FwNw9.3600.1311487200.0-29000387|0aZ4-swEk1RJo8PWMgzAqj-Daqs
The id field is your uid aka user id. If you don't have an app id, don't worry about it. You only need fb:admins OR fb:app_id. Not both.

Facebook: Get all "Likes" for a specific page

I am currently planning a facebook integration on our website. In the example given at the Getting Started page (http://developers.facebook.com/docs/opengraph), you can see that I like "The Rock" on Imdb. If I were Imdb, would it be possible to query the user object to get all likes on Imdb? For example would it be possible for them to build a page like "these are the films where you clicked the like button on our website"?
Thank you for your answer!
To get the likes for a page you need to do this:
use http://graph.facebook.com/
this will return a JSON object be default. Just snatch the likes property off it.
http://graph.facebook.com/wearex3 for example
But what you are asking requires you to request access to the user's data and from there get all the likes.
http://developers.facebook.com/docs/opengraph and http://developers.facebook.com/docs/guides/web are what you want to read.