4
votes

I am trying to import friend from my LinkedIn profile. So I am using LinkedIn API from this link https://developer.linkedin.com/documents/code-samples.

I am using my API key and secret key here.

I am getting my name back when I am login with my LinkedIn credential. However, when I am trying to import my connection by changing option I am getting error.

Code I am using for import connection:

$user = fetch('GET', '/v1/people/~/connections:(headline,first-name,last-name)');
print_r($user);

Error that I am getting:

Warning: file_get_contents(https://api.linkedin.com/v1/people/~/connections:(headline,first-name,last-name)?oauth2_access_token=AQWccNaOhPHIcKr_pdkQjvz3Ri_ZF2goNdVdaXJgDDO3PIbyvIQ2MEDqtKMP6szRbbzVG003v5ALE198H7J8TDLnuVFOe5MGetOBdNxrOFrk4KKeFsi3Lf5SLuVGtMA2YSj7hQ-h5QA7ZaDGbt95bpfHOL7nMDyIxd69yFG2BYA9CWesCVw&format=json)

[function.file-get-contents]: failed to open stream:
HTTP request failed!
HTTP/1.0 403 Forbidden in /opt/lampp/htdocs/open-inviter/api.php on line 111

Any clue or help.

1
is the access_token valid or expired ?Dinesh Kumar Sarangapani
Hit the url in browser api.linkedin.com/v1/people/~/… . It is not working.Rohan Kumar
It will not work because before that I have to login locally with my linkedin credentials. You can try it with that code.Amar Banerjee

1 Answers

0
votes

Finally I got the error. I have to the permission to access my connect during authorisation. I have added 'r_network' on this line define('SCOPE','r_fullprofile r_emailaddress rw_nus r_network');. It works now :)

Thanks