I will start by admitting I am not experienced in PHP and am very new to the LinkedIn API. But I set up a new Apache/PHP server yesterday and have had success in getting a user to (1) grant authorization to access their r_fullprofile and r_emailaddress, (2) exchanging the authentication code for a 60 day access token and (3) making an initial call to retrieve the user's LinkedIn profile and display results. So I'm excited about that.
But not everything worked, which is what I wanted to ask about.
I'm basing my code on the sample PHP code LinkedIn makes available at https://developer.linkedin.com/documents/code-samples. (Minor question, since I'm new to PHP, but it seems to me they left out a closing ?> at the end of their code. Maybe that's not required at the end of a PHP file? Anyway, I put it in just in case.)
The differences between their code and mine are few.
(1) Their code defines the scope this way:
define('SCOPE', 'r_basicprofile r_emailaddress');
but I asked the user for access to their full profile, so I defined the scope this way:
define('SCOPE', 'r_fullprofile r_emailaddress');
(2) The sample code just requests two profile fields:
$user = fetch('GET', '/v1/people/~:(firstName,lastName)');
I wanted a lot more, so I requested all these profile fields as defined at https://developer.linkedin.com/documents/profile-fields:
$user = fetch('GET', '/v1/people/~:(firstName,lastName,headline,industry,specialties,summary,positions,public-profile-url,email-address,interests,publications,languages,skills,certifications,educations,num-recommenders,date-of-birth,honors-awards)');
The request is successful and profile fields are returned and shown. But there are some problems with some of the fields I wanted to ask about.
After the successful return I use print statements to show the results:
print "<br />Hello $user->firstName $user->lastName. We have successfully retrieved the following information from your LinkedIn Profile.<br />";
print "<br />headline: $user->headline ";
print "<br />industry: $user->industry ";
print "<br />specialties: $user->specialties ";
print "<br />summary: $user->summary ";
// print "<br />positions: $user->positions ";
print "<br />public-profile-url: $user->public-profile-url ";
print "<br />email-address: $user->email-address ";
print "<br />publications: $user->publications ";
// print "<br />languages: $user->languages ";
// print "<br />skills: $user->skills ";
print "<br />certifications: $user->certifications ";
// print "<br />educations: $user->educations ";
print "<br />num-recommenders: $user->num-recommenders ";
print "<br />date-of-birth: $user->date-of-birth ";
print "<br />honors-awards: $user->honors-awards ";
print "<br /><br />Thanks. We hope this helps make your experience more professionally rewarding for you.";
The displayed result of all the print statements above look like the following (though I have shortened the summary here for brevity's sake):
Hello Doug Lerner. We have successfully retrieved the following information from your LinkedIn Profile.
headline: Founder & CEO, Elliptics, Ltd.
industry: Computer Software
specialties:
summary: Although I am a U.S. citizen, since 1983 I have resided in Tokyo, where I hold permanent residency. During my first 7 years in Japan, I worked for Fujitsu, the largest computer company in Japan. At Fujitsu I was Technical Director for Fujitsu's 1990 Osaka World's Fair Omnimax/IMAX production "Echoes of the Sun". For 14 years at Nippon Electronics College, I lectured in Mathematics and Scientific Simulation in the Department of Computer Graphics, where I also served as the Director of the Virtual Reality Seminar program.
public-profile-url: -profile-url
email-address: -address
publications:
certifications:
num-recommenders: -recommenders
date-of-birth: -of-birth
honors-awards: -awards
Thanks. We hope this helps make your experience more professionally rewarding for you.
One major question I have is with regards to the print statements I have commented out above. The last print is a confirmation to me that I successfully reached the end of the script. However, if any of those commented out print statements are included the script stops right there and nothing further is printed out.
As I mentioned, I am not that experienced with PHP so one problem is I don't know what the problem is with those particular print statements. No error message is displayed (I suspect the default setup suppresses error messages so they aren't displayed to users). So one thing I would like to know, especially when testing, is what errors are encountered.
Why would those particular profile fields: positions, languages, skills and educations cause a problem? Since the profile field names are plurals, one guess is that maybe what is returned is not a simple string which can be shown with print and they are maybe arrays or something else which requires a different way to display them. I didn't see more definitions about the values of those particular fields in the docs, so if somebody could help me with information about them I would be grateful.
Some "plural sounding fields" just returned blanks: specialties, certifications, publications so I'm guessing those had null values rather than some specially formatted list of values to be shown in a special way.
Other print statements work, and show the actual profile content (e.g. my industry is printed as Computer Software (obviously not PHP though), or in some cases a string with a minus in front of it. For example, public-profile-url: -profile-url.
As for the values with a minus in front of it, what does that mean? Why is my public-profile-url returned as -profile-url? Does it mean a hidden field? I don't see where I can even hide that.
I would be grateful for any information people can provide.