Integration with LinkedIn.com Part 1

If your site is a business-oriented community, consider integrating it with LinkedIn.com in order to draw targeted, business-minded visitors and members. Given LinkedIn’s focus on business and technical professionals, it is an excellent potential source of social traffic to your site; simply adding an “invite friends” button from LinkedIn will allow you to draw IT and business specialists directly from LinkedIn to your website.

Talking about “integrating” is one thing; how does one integrate in practice? LinkedIn provides its members with a simple, well-documented API to allow for this and other off-site functions. The OAuth protocol, used by LinkedIn to authorize its account holders, allows you to integrate the content you create on LinkedIn with your website without the need to store the account password locally. While working with OAuth is not necessarily a simple thing, free libraries like this one (that I personally use) exist on the web to make the process an easier one.

The first step is to register your site with LinkedIn; this will in turn provide you with the API key and Secret key, each of which is needed to proceed. The keys are used to authorize users in these steps:

1. First we’ll create a temporary token for the user; this will later be used until a permanent access token is generated:

$linkedin = new LinkedIn($linkedin_api_key, $linkedin_secret_key, $linkedin_callback_url);
 
$linkedin->getRequestToken();

Here, $linkedin_api_key and $linkedin_secret_key are the keys obtained from LinkedIn upon registering of our application, and $linkedin_callback_url is the url on your site where the user will be redirected after authorizing.

Now a Request token is generated and gets in $linkedin->request_token where it must be retained, for example in a database.

2. Direct the user to a custom URL, formatted with the help of a Request token

header("Location: " . $linkedin->generateAuthorizeUrl());

Here the user will see a form for authorization where they’ll need to enter their email address and password. Following this, the user will be redirected back to your site, specifically to an URL which will be defined when the object is created by LinkedIn.

3. Now we need to create an object called LinkedIn and include within it all of the data necessary to generate an Access Token.

$linkedin = new LinkedIn($linkedin_api_key, $linkedin_secret_key, $linkedin_callback_url);
 
$linkedin->request_token = '';
 
$linkedin->oauth_verifier = $_REQUEST['oauth_verifier'];

Here, $ _REQUEST ['oauth_verifier'] is a variable passed by LinkedIn.

4. Now we can generate the Access Token.

$linkedin->getAccessToken($oauth_verifier);

The code: $ linkedin-> access_token must be stored in the database for future usage.

All of these actions must be completed only during the first connection of a user to LinkedIn from your website; in the future, the same user will be able to connect to LinkedIn using the Access Token in your database:

$linkedin = new LinkedIn($linkedin_api_key, $linkedin_secret_key, $linkedin_callback_url);
 
$linkedin->access_token = < obtained from the database >;
 
// obtain data about the user
 
$xml_response = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url)");
This entry was posted in PHP Tips.

307 Responses to Integration with LinkedIn.com Part 1

  1. Pingback: Alexander

  2. Pingback: Alexander7

  3. Pingback: LUKE

  4. Pingback: FREDDIE

  5. Pingback: ANGEL

  6. Pingback: SETH

  7. Pingback: BRANDON

  8. Pingback: PERRY

  9. Pingback: TERRENCE

  10. Pingback: SALVADOR

  11. Pingback: DUSTIN

  12. Pingback: OTIS

  13. Pingback: LEO

  14. Pingback: LEWIS

  15. Pingback: GUY

  16. Pingback: CHARLIE

  17. Pingback: ALFRED

  18. Pingback: JEFFREY

  19. Pingback: KIRK

  20. Pingback: WALLACE

  21. Pingback: RUSSELL

  22. Pingback: ENRIQUE

  23. Pingback: RENE

  24. Pingback: DONNIE

  25. Pingback: ROLAND

  26. Pingback: JIMMIE

  27. Pingback: ALFRED

  28. Pingback: MIKE

  29. Pingback: BRADLEY

  30. Pingback: JAMES

  31. Pingback: ROY

  32. Pingback: PERRY

  33. Pingback: CLAUDE

  34. Pingback: KURT

  35. Pingback: LANCE

  36. Pingback: DENNIS

  37. Pingback: TRACY

  38. Pingback: RALPH

  39. Pingback: BRETT

  40. Pingback: SAMUEL

  41. Pingback: RICARDO

  42. Pingback: FELIX

  43. Pingback: DONALD

  44. Pingback: KELLY

  45. Pingback: ALVIN

  46. Pingback: JUAN

  47. Pingback: VICTOR

  48. Pingback: BRADLEY

  49. Pingback: TONY

  50. Pingback: RICK

  51. Pingback: NATHAN

  52. Pingback: BRUCE

  53. Pingback: MATHEW

  54. Pingback: KENNY

  55. Pingback: WILLIAM

  56. Pingback: CARL

  57. Pingback: ADAM

  58. Pingback: LOUIS

  59. Pingback: JIMMY

  60. Pingback: RUBEN

  61. Pingback: BOB

  62. Pingback: ANDREW

  63. Pingback: ALBERT

  64. Pingback: BYRON

  65. Pingback: JONATHAN

  66. Pingback: MARCUS

  67. Pingback: RODNEY

  68. Pingback: SERGIO

  69. Pingback: DARYL

  70. Pingback: VICTOR

  71. Pingback: RAY

  72. Pingback: CLIFTON

  73. Pingback: LLOYD

  74. Pingback: JEREMIAH

  75. Pingback: BRANDON

  76. Pingback: LUIS

  77. Pingback: ALEJANDRO

  78. Pingback: SAMUEL

  79. Pingback: EVERETT

  80. Pingback: LAWRENCE

  81. Pingback: TIM

  82. Pingback: MITCHELL

  83. Pingback: PHILIP

  84. Pingback: JERRY

  85. Pingback: ALFRED

  86. Pingback: LEWIS

  87. Pingback: BRUCE

  88. Pingback: MARION

  89. Pingback: BRYAN

  90. Pingback: VINCENT

  91. Pingback: GLENN

  92. Pingback: BRETT

  93. Pingback: LEROY

  94. Pingback: RONALD

  95. Pingback: JASON

  96. Pingback: MARVIN

  97. Pingback: CHRISTOPHER

  98. Pingback: BRUCE

  99. Pingback: AUSTIN

  100. Pingback: GERARD

  101. Pingback: MARION

  102. Pingback: RONNIE

  103. Pingback: DALE

  104. Pingback: WENDELL

  105. Pingback: JORGE

  106. Pingback: VERNON

  107. Pingback: CHRIS

  108. Pingback: NICHOLAS

  109. Pingback: DWIGHT

  110. Pingback: VINCENT

  111. Pingback: RICARDO

  112. Pingback: CARLOS

  113. Pingback: FRED

  114. Pingback: RAUL

  115. Pingback: AARON

  116. Pingback: ALVIN

  117. Pingback: EVAN

  118. Pingback: BILLY

  119. Pingback: DAVID

  120. Pingback: BRENT

  121. Pingback: WENDELL

  122. Pingback: FREDRICK

  123. Pingback: EARL

  124. Pingback: WENDELL

  125. Pingback: BRYAN

  126. Pingback: ANGELO

  127. Pingback: OLIVER

  128. Pingback: JULIUS

  129. Pingback: ALBERTO

  130. Pingback: ALFRED

  131. Pingback: HUBERT

  132. Pingback: MICHAEL

  133. Pingback: MAX

  134. Pingback: DAN

  135. Pingback: ERIC

  136. Pingback: RICK

  137. Pingback: BRENT

  138. Pingback: OLIVER

  139. Pingback: RONNIE

  140. Pingback: MARTIN

  141. Pingback: FERNANDO

  142. Pingback: RAFAEL

  143. Pingback: TYLER

  144. Pingback: OLIVER

  145. Pingback: greg

  146. Pingback: TREVOR

  147. Pingback: BRANDON

  148. Pingback: LESTER

  149. Pingback: TERRY

  150. Pingback: MAURICE

  151. Pingback: LESLIE

  152. Pingback: LANCE

  153. Pingback: STEPHEN

  154. Pingback: PATRICK

  155. Pingback: ALFREDO

  156. Pingback: DUSTIN

  157. Pingback: LESTER

  158. Pingback: JOHNNY

  159. Pingback: LUIS

  160. Pingback: FREDDIE

  161. Pingback: MICHAEL

  162. Pingback: MIKE

  163. Pingback: OSCAR

  164. Pingback: PETER

  165. Pingback: RALPH

  166. Pingback: DUSTIN

  167. Pingback: JESUS

  168. Pingback: LEON

  169. Pingback: ROGER

  170. Pingback: BILLY

  171. Pingback: FRANCIS

  172. Pingback: DALE

  173. Pingback: NORMAN

  174. Pingback: STUART

  175. Pingback: MILTON

  176. Pingback: ALFREDO

  177. Pingback: LESLIE

  178. Pingback: KYLE

  179. Pingback: AUSTIN

  180. Pingback: BRADLEY

  181. Pingback: FRANKLIN

  182. Pingback: JERRY

  183. Pingback: NICK

  184. Pingback: KENNETH

  185. Pingback: JIMMIE

  186. Pingback: AUSTIN

  187. Pingback: DON

  188. Pingback: LEONARD

  189. Pingback: JORGE

  190. Pingback: CLINTON

  191. Pingback: ALFRED

  192. Pingback: TRAVIS

  193. Pingback: JEFFERY

  194. Pingback: FREDERICK

  195. Pingback: HOWARD

  196. Pingback: KEVIN

  197. Pingback: ROBERTO

  198. Pingback: FREDDIE

  199. Pingback: BILLY

  200. Pingback: KIRK

  201. Pingback: MILTON

  202. Pingback: NICHOLAS

  203. Pingback: WADE

  204. Pingback: ENRIQUE

  205. Pingback: PEDRO

  206. Pingback: DOUGLAS

  207. Pingback: JESSIE

  208. Pingback: CHRIS

  209. Pingback: FRANCIS

  210. Pingback: JAY

  211. Pingback: CURTIS

  212. Pingback: GORDON

  213. Pingback: ADAM

  214. Pingback: DENNIS

  215. Pingback: CALVIN

  216. Pingback: JAMES

  217. Pingback: RENE

  218. Pingback: ANDREW

  219. Pingback: ANDRE

  220. Pingback: KENT

  221. Pingback: TERRENCE

  222. Pingback: GERALD

  223. Pingback: MELVIN

  224. Pingback: JULIO

  225. Pingback: MARC

  226. Pingback: ALFREDO

  227. Pingback: PATRICK

  228. Pingback: JACOB

  229. Pingback: ANDREW

  230. Pingback: SERGIO

  231. Pingback: FREDRICK

  232. Pingback: JOSHUA

  233. Pingback: LOUIS

  234. Pingback: STEPHEN

  235. Pingback: WESLEY

  236. Pingback: JOEL

  237. Pingback: BILL

  238. Pingback: BILLY

  239. Pingback: ERIC

  240. Pingback: NEIL

  241. Pingback: WAYNE

  242. Pingback: WALLACE

  243. Pingback: SHAWN

  244. Pingback: KENT

  245. Pingback: ELMER

  246. Pingback: NELSON

  247. Pingback: JUSTIN

  248. Pingback: MARCUS

  249. Pingback: JUAN

  250. Pingback: JOEY

  251. Pingback: GUY

  252. Pingback: JEREMIAH

  253. Pingback: WESLEY

  254. Pingback: NATHAN

  255. Pingback: MITCHELL

  256. Pingback: ZACHARY

  257. Pingback: LUKE

  258. Pingback: DONALD

  259. Pingback: ROBERT

  260. Pingback: CASEY

  261. Pingback: ROSS

  262. Pingback: KEN

  263. Pingback: ALFREDO

  264. Pingback: RANDALL

  265. Pingback: LYNN

  266. Pingback: LEE

  267. Pingback: VERNON

  268. Pingback: RICK

  269. Pingback: GUY

  270. Pingback: EDWIN

  271. Pingback: JEFF

  272. Pingback: WALLACE

  273. Pingback: ALEJANDRO

  274. Pingback: LUTHER

  275. Pingback: ARTURO

  276. Pingback: DALE

  277. Pingback: ANDRE

  278. Pingback: TROY

  279. Pingback: DAVE

  280. Pingback: ALFRED

  281. Pingback: HARRY

  282. Pingback: RUSSELL

  283. Pingback: NATHANIEL

  284. Pingback: MILTON

  285. Pingback: MARION

  286. Pingback: FERNANDO

  287. Pingback: LAWRENCE

  288. Pingback: RAMON

  289. Pingback: JIM

  290. Pingback: DAN

  291. Pingback: ENRIQUE

  292. Pingback: VIRGIL

  293. Pingback: CHRISTIAN

  294. Pingback: JOHNNIE

  295. Pingback: GARY

  296. Pingback: ALFRED

  297. Pingback: JUAN

  298. Pingback: SHANE

  299. Pingback: LANCE

  300. Pingback: TRACY

  301. Pingback: REGINALD

  302. Pingback: jordan

  303. Pingback: STANLEY

  304. Pingback: JOHN

  305. Pingback: HUGH

  306. Pingback: nathaniel

  307. Pingback: JACKIE

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">