Get facebook logged in user's ID on ASP CLASSIC - facebook

in a facebook app iframe tab, Is it possible, i tried with the JS SDK but then the user needs to allow that.
how can i get only his user id with classic asp?

Your website can't get at the user's Facebook Id in any way unless the user allows it. Period. Thank God -- I mean Zuck.

In short, When facebook contact your canvas url for displaying your tab, it set POST data that contains a signed_request parameter which contains amongst other :
a user field : A JSON array containing the locale string, country string and the age object (containing the min and max numbers of the age range) for the current user.
So no user id !
If you want to know more about your user, you have to go through the auth/permissions process. After that, in subsequents displays of your canvas, the user_id and oauth_token (and others) fields will be added to the POST variables.
More at : http://developers.facebook.com/docs/guides/canvas/#auth
This is also true for the "full app" view now that they have harmonized full apps and tab apps. The only difference now is the width of the iframe (520px for tab, 760px for full)

Related

trying to get both the userID and the ID of the profile where the clicked on the app

I am designing an app that lets one facebook user commission another user. I'm new to the facebook API, but I'm doing my best - hopefully someone can point me in the right direction.
The app does the following:
1) Once authorized, it creates a tab on your timeline.
2) Then another facebook user clicks on this tab.
3) once they authorize and give permission, I want to capture the user id of the logged in user (this is easy) and the ID of the profile on which they clicked to install the app (this I can't do). I'm sending these off to a MySQL server.
So am I capturing two distinct userIDs? Or a userID and a pageID? any help very appreciated!
Well you simply can't add applications to a user's profile. So what you are seeing is a PAGE_ID (assuming you mean that the application was installed on a page's timeline), and a USER_ID.
You'll find all this information in the signed_request that is passed to the page. Once you have decoded this signed_request the page info is in the page parameter -
page - A JSON object containing the page id string, the liked boolean (set to true if the user has liked the page, false if not) and the admin boolean (set to true if the user is an admin of the page, false if they're not). This field is only present if your app is being loaded within a Page Tab.
And the user info is in the user parameter -
user - A JSON object containing the locale string, country string and the age object. See the Age Object table for actual min and max values.

Linking to a page tab app on a Facebook page

Is there a reliable way to link to an app on a Facebook page, when only the page ID and app ID are known? Specifically the URL to the page is not known, only the ID.
The documentation at https://developers.facebook.com/docs/authentication/pagetab/ claims that the following should work:
https://www.facebook.com/pages/null/PAGE_ID/app_YOUR_APP_ID
However when I try this, for example http://www.facebook.com/pages/null/126169047465269/app_222972467721305 does not work and instead I get "This content is currently unavailable".
The best form that will always work for a numeric page ID is this:
https://www.facebook.com/pages/null/PAGEID?sk=app_APPID
Replace PAGEID and APPID with numeric IDs.
If instead of a numeric page ID you have a username, then the URL should be of this form:
https://www.facebook.com/PAGEUSERNAME?sk=app_APPID
or
https://www.facebook.com/PAGEUSERNAME/app_APPID
The Page here is not Public or maybe is not available?:
https://www.facebook.com/pages/126169047465269/
Try this,
https://www.facebook.com/PAGE_NAME_OR_ID/app_222972467721305
In the PAGE_NAME_OR_ID add pages/126169047465269,
if your page have a custom slug add the slug.
But to be sure check if your app is in a Sandbox mode or Unpublished.

Is it possible to change avatar image and settings on Facebook (through Graph API) of a page created through the “Like” button plugin?

1) Paper.li enables people to publish online newspapers from their favorite social media. An example is here : http://paper.li/tag/socialmedia. All the pages are provided in six languages (English, German, French, Spanish, Portuguese, Japanese).
2) For each of these pages, we are inserting OpenGraph meta information in the source of the page as described in Facebook documentation (https://developers.facebook.com/docs/opengraphprotocol/). We insert the following metas :
a. og:title : The paper title inserted by the user on our service.
b. og:description : A standard description for all pages on our service.
c. og:type : We do not used a standard type provided by Facebook here and we know that the page is classified in “Others” by providing the following value “paper_li:newspaper”.
d. og:url : This is the paper URL.
e. og:image : This is the image of the first article shown in the page to the user. (this is the most relevant content for this page).
f. og:site_name : This is top domain of the app, we mean here “paper.li”
g. fb:app_id : This is the Facebook Application Id we use for our service (providing a Facebook Tab App and login on our service too). This app can be accessed through the following URL on Facebook : http://www.facebook.com/362293833600.
h. og:locale : It defines the current language used by the user on our service
i. og:locale:alternate : It defines all the five other languages we support on our service
This meta information is working really well when using the send button or the like button with social plugins.
3) Our service provides papers who are updated every 24 hours on the same URL (each daily edition is served on one unique URL corresponding to the paper). By this, it means that “og:image” can change (that’s 99.9% of cases) daily, because first article fetched on the web will change daily and image too (corresponding to point 2.e). Paper title (indicated in OpenGraph meta by the point 2.a) can be changed by the user at any time too. In this example, the title is in Japanese in the Graph, for example, with always the same avatar picture in the wall posts.
4) As it’s suggested in your documentation, we want to use the publishing functionality from Facebook linked with the “Like” button. By this, it means that every time a paper is updated on our service, our service is publishing automatically a status to the page corresponding on the Graph on Facebook with the daily headlines (article title, description and image) through the GraphAPI. By doing this, every user having liked the page with the “Like” button will get the status in his news feed if Facebook decides to show it. That’s the purpose of the “Like” button and it’s working really well.
The problem is the following: when we access each of these pages liked on Facebook as an administrator (with application authentication token), we can publish statuses (what we are already doing), but they are published with a page avatar corresponding to the first “og:image” meta that was fetched by Facebook at the first “Like” of this page. It means users are seeing an image for this page that is not corresponding to the content (statuses) published by the page. Same problem appears with the title (if a user is changing it on our side, it can’t be updated on Facebook).
We find it very strange as for standard pages (created by “Create a page” button on Facebook), an access to “Profile picture” and page settings is provided as we don’t have it for pages created through the “Like” button plugin placed on our website (even if we are admin of the page through the app_id). The only way for us to change it for future pages is to change “og:image” meta information but it means that no more relevant image will be shared with corresponding URL (when sharing it in a status at a specific time, for example).
In conclusion, our question is the following: Is it possible to change avatar image and settings (title, ..) on Facebook (through Graph API) of a page created (in the Graph) through the “Like” button plugin? What would be the impact of this action?
In conclusion, our question is the following: Is it possible to change
avatar image and settings (title, ..) on Facebook (through Graph API)
of a page created (in the Graph) through the “Like” button plugin?
No, pages cannot be created via the Like plugin. But if you're referring to a feed post being created, then still no because your app did not insert it.
What would be the impact of this action?
If any authenticated app can change people's posts, regardless of which app created the posting, to their feed, then it might lead to abuse of the system.

Facebook thinks my Admin ID is my App ID for Open Graph, calls it invalid

I created a page and put the account name (from facebook.com/<account-name>) of the page in the fb:admins field and left the App ID field blank. When i test the Like button it says the App ID is invalid and lists the ID number of the page (note, there is no app, this is just a normal page). I also tried putting in the ID number that I get from graph.facebook.com/<account-name> and still it doesn't work. Running the Linter (https://developers.facebook.com/tools/debug) shows the error: "You put ### in the fb:admins field. It should be in fb:app_id"...still, no app exists so I don't know why it thinks the ID is an app ID.
When I put a different user's ID in the admin ID field it works fine, but not if I'm following it using a page.
Check out this doc. You can't use a page_id to administer a page, you can only use a UID or an AppID. The fb:page_id is related to Insights, not OG administration.

Facebook Get User ID From Application Tab

Facebook apps are allowed to have a tab that a user can add to his profile's tabs if he wants.
How can I get the uid or otherwise identify the currently logged in user in order to customize the layout for him please?
Thank you.
As noted here:
Facebook does not pass back who the viewing user is when she first visits your tab. Facebook does send the profile owner's ID in the fb_sig_profile_user parameter, so you know whose profile to display content for.
Visitor id is passed as request parameter after a user interacts with your tab. I can't find exact parameter name as they removed a wiki page that used to contain a list of all passed parameters, but if you dump all your request vars you should be able to see it (but not during the first visit).
some sources to do it + you must have turned on all items on migration in app settings
http://nathrondevblog.blogspot.com/2010/09/how-to-get-user-id-in-profile-tab.html
Try out this one,
If the user is logged in. You can directly get the user_id, session_key etc from the querystring.
long fbuid = long.Parse(Request.QueryString.Get("fb_sig_user"));