Linkedin Profile API vs Publicly Available URIs - php

I have a database of people's names and LinkedIn profile URLs.
Annoyingly there isn't a standard format for LinkedIn URLs (like twitter) but there are generally in the form of:
1) http://www.linkedin.com/in/geoffroyondet
2) http://www.linkedin.com/profile/view?id=34178115
On my site I want to display people's LinkedIn details.
I've got OAuth working fine and for people with the first format (above) I can successfully display their LinkedIn data on my site. I'm using the "Public Profile URL" option from https://developer.linkedin.com/documents/profile-api
But for the second format I'm having problems. It's invalid as a "public profile" and the ID in the URL doesn't seem to be the "member_id" from the link above.
Btw, if I try to use this numeric ID as a member_id I get the following error:
object(SimpleXMLElement)[652]
public 'status' => string '404' (length=3)
...
public 'message' => string 'Invalid member id {34178115}' (length=28)
From poking around with the API the only way I can get the alphanumeric id (member_id) is from a successful API call (blah->person->id). But to make a successful API call I first need a valid URI. So it seems to be a chicken and egg situation.
Any suggestions as to how I can display LinkedIn data by using the second URL above?

Looks like there are two issues here at play:
1) The technical issues. You are correct that you cannot retrieve a user's profile via the Profile API via the second URL, you can only do it via the unique public-profile-url, via the member ID, or via the ~ to retrieve the current user's profile.
Member ID is not related to the number you see in the query string - the member ID is a alphanumeric token generated uniquely for each user for each API application, so user A via your application will have a different member ID than the same user A via my application.
Are you just retrieving the member profiles arbitrarily or are you trying to retrieve profile information from connections of the viewing authenticated user? You should be able to either pull the viewer's connections public-profile-url, or pull it via a People Search, etc.
2) The platform guidelines. Basically, you can only show profile information about a particular LinkedIn user to viewers by pulling the information on behalf of that user. Meaning, that the viewer has authenticated against the API; you don't mention whether this will be the case, but adhering to #2 will potentially help solve #1.

Related

Is there a way to determine whether a facebook url leads to a profile or a page through facebook php sdk?

The users of my website can add facebook fanpages and profiles to the website. I am trying to figure out a way, to determine whether a url that was added leads to a facebook profile or to a facebook fanpage.
I have the facebook php-sdk version 5 installed on the website and I also have valid access tokens for my own profile.
Is there a way to find out whether any given facebook url leads to a profile or a fanpage without having and access token to either of them?
Is there a way to find out whether any given facebook url leads to a profile or a fanpage without having and access token to either of them?
No official one.
You can still try and make an educated guess, if you got a profile URL that contains a username (user or page).
Trying to access a user profile that you have no access to this way, currently still results in the error message, “(#803) Cannot query users by their username (xyz).” Facebook introduced this error message after they removed the username field from the user object.
If it is a page instead, and again you have no token that specifically grants access, then you should get the error “(#10) To use 'Page Public Content Access', your use of this endpoint must be reviewed and approved by Facebook. […]” (assuming that your app doesn’t have this feature reviewed & approved; if it had, you should be able to read basic public page data using this request, so you could draw your conclusions from that.)
That would be for pages that are currently public and have no access restrictions; if that wasn’t the case, you should get the message, “(#10) Object does not exist, cannot be loaded due to missing reviewable feature 'Page Public Content Access', or does not support this operation. […]”
But there might also be other situations. Not every user has a username set for their personal profile - and if you got a numeric user id only, you’d get “Unsupported get request. Object with ID 'xyz' does not exist, cannot be loaded due to missing permissions, or does not support this operation.” But that message is not specific to user profiles, you might get it regarding other objects you simply do not have access to as well.
And on top of that, Facebook might probably changes this, if they feel that this exposes more information than they are comfortable with. They might switch to a more generic error message covering all those cases at some point, or something like that.
Unless you absolutely have to make sure that your app knows what’s a user profile and what’s a page, I would recommend against trying this - and rather trust your users that they will pay a bit of intention, if the result matters to them.
Edit: One more thing that could be - partially - used, is the syntax to get information about “external” Open Graph objects, by specifying the URLs using the ?ids=… syntax. A request for ?ids=https://www.facebook.com/zuck,https://www.facebook.com/facebook currently yields the following result,
{
"https://www.facebook.com/facebook": {
"name": "Facebook",
"id": "20531316728"
},
"https://www.facebook.com/zuck": {
"id": "https://www.facebook.com/zuck"
}
}
As you can see, for the first one, which is the official page for Facebook, it returns the page ID, whereas for the second one, which is Mark’s personal profile, it doesn’t. But, careful - for non-public pages, you would not get any ID here either. But maybe in combination with the aforementioned requests, that will result in different error messages depending on the type of object, that could increase the quality of the “educated guess” here.

Facebook API return different IDs for the same user [duplicate]

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user
{
self.profilePictureView.profileID = user.objectID;
self.nameLabel.text = user.name;
NSLog(#"My ID:%#", user.objectID);
}
I have tried to print the user id using the above code. And what I get is 3176144783XXXXX.
However, I got a different one using this online tool http://findmyfacebookid.com/. The result is 1000042591XXXXX.
Does anyone know the difference? Why do my app and 'findmyfacebookid.com' receive a different user ID for the same user?
Note: My mobile app need to use the FB unique ID to create my own user database. So this is the reason I need a unique ID.
Since v2.0 of the Facebook API the user IDs returned to your app are scoped to your app (i.e each app receives a different identifier for any given user) - you can't compare what that site is telling you to what your app received when you called user.objectID because they're intentionally different strings
Use the ID returned to your app as the identifier for users in your app - there's no need to try and find the 'real' or 'old' user ID - there's no reason for you to need to use the user ID given to any other app ID
There's more information about that the changes from v1.0 to v2.0 here: https://developers.facebook.com/docs/apps/upgrading
And the app-scoped IDs are specifically discussed here, including a way for developers with multiple apps to corelate the IDs for users who use more than one of their apps : https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids

Get user info from google plus using php

How do I get user info like profile picture, location, description etc.
I have a field in form called google+ url. Now If any user filled it with their google+ url, I want to get their profile picture, location and description using their google+ url, Is it possible without creating google+ application?
A Google+ URL generally contains the Google+ ID for a user. You can parse out that ID, and then make a people.get API call using the ID. The response will only contain information that is publicly available on the user's profile, though. Also, if a user is verified, their URL will not contain their ID, but rather their verified name, but this will also work as an ID.
In PHP, the call looks like: $me = $plus->people->get('{{ID}}');
You can learn more about the people.get API call and see a full example at https://developers.google.com/+/api/latest/people/get.

Get facebook posts/events/news/gallery with javascript (or php) inside my website

I'm tryin to develop a (almost) 100% client-side dynamic website by integrating it with twitter, facebook and flickr.
I've been able so far to get the last 4 tweets (with javascript) from my client's feed, and now i was wandering if i could do the same with facebook's gallery and events from their feed.
Especially, what i need (given the facebook username/api key/whatever)
gallery
for each gallery in user's profile:
get the gallery name
get the first picture
get the gallery url
news/events
for each news/event/post in user's profile:
get the event name
get the event text
get the event picture (if provided)
get the event url
I don't want to use the facebook widgets with their rendering, i just need to read the json response (if there's any) and put the data inside my website (like a preview).
Since my client is pretty rusty with "computers (cit.)" but he's (not so strangely) comfortable with facebook/twitter/flickr, i tought about a solution like this before adding a database and an admin interface to our website.
I found some resources online, so i think it's possible (in a way or another). I'd like to do it in javascript, but if it's php i won't complain.
Check out this API to get photoes from the user profile
http://developers.facebook.com/docs/reference/api/album/
This is for events
http://developers.facebook.com/docs/reference/api/event/
You can use either the PHP or the Javascript API SDKs:
http://developers.facebook.com/docs/reference/php/
http://developers.facebook.com/docs/reference/javascript/
respectively. Naturally you would handle the returned information differently. Both have a method called api() which can be utilised to grab the album and event objects (as mentioned in another answer):
http://developers.facebook.com/docs/reference/api/album/
http://developers.facebook.com/docs/reference/api/event/
You can pass parameters in the methods to restrict the results returned by fields, number of items, sizes of images etc. This is outlined here:
http://developers.facebook.com/docs/reference/api/
But the issues you are going to face is that you have to authorise your "app" - think website when they use the terminology "app" - to give it permissions to access the information. This takes the form of a two step process. You have to create the app on the Facebook platform which can then access the API methods (only certain information can be got from the API methods without an authenticated app).
The second part is that the user themselves must then authenticate their facebook account against your app - this gives your app permission to access the user's information. In plain English it would go like this:
User visits your webpage; user must be logged into Facebook and must approve your app (this used to be called Facebook Connect for obvious reasons); the app and the user account are "connected"; the app can then use the api methods you've written to return information about the connected user
The beginning explanations of how to do this are here:
http://developers.facebook.com/docs/authentication/
The only way you can access a user's (non-public) information from outside of Facebook is via a connected app and user profile.

Facebook getUser returns wrong ID

I have an problem in my app. The only thing I need from a user is there facebook id. After they log onto facebook they are redirected back to my app and I can get the userID with $facebook->getUser(). This works fine except when the user has chosen a username on facebook. Then I get a really weird long ID that is different from the userid.
To clarify, let's say I ask the userid from a user that hasn't set a username, I get for example the id: 1234567891.
When a user has set a username, I get an ID like: 100002339295322.
Anyone maby knows how I can solve this ?
If you need code samples of how I do things, I do them as told on the facebook developers site: http://developers.facebook.com .
With friendly greetings,
Bob
PS: I use the CodeIgniter framework and the official facebook php sdk
*/// EDIT \*
The problem is solved. Apparently it had something to do with the datatype I used for the field. I changed it from int to varchar and now everything is working.
I had a similar problem, and found out that after v2.0 API user_id is app scoped. I had two user_id for the same user's profile but different application, and both are valid for their respective app.
You can reach the user profile with
http://facebook.com/app_scoped_user_id/<USER_ID>
You may also query the graph api, using the app token and the app scoped user id.
Ref.: https://developers.facebook.com/docs/apps/upgrading/#upgrading_v2_0_user_ids
Not all facebook users have usernames but they ALL have user ids. (e.g. it's optional to have an alphanumeric username, just gives easy access - facebook.com/johnsmith or smth)
Your best bet is to store the ID (the 10 or so digit number) and if you're storing names, perhaps store their first name like stackoverflow does.
For those coming here after 1 May 2014, Test Apps now default to the v2 API, which will cause problems if your app was built using v1. See last post in the FAQ here https://developers.facebook.com/docs/apps/test-apps

Categories