Login   Register  
PHP Classes
elePHPant
Icontem

PHP OAuth class Post to user's LinkedIn Account

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      PHP OAuth API  >  All threads  >  PHP OAuth class Post to user's LinkedIn Account  >  (Un) Subscribe thread alerts  
Subject:PHP OAuth class Post to user's LinkedIn Account
Summary:Having trouble creating the CALLAPI function correctly
Messages:47
Author:Bill Egan
Date:2012-12-13 15:48:55
Update:2014-01-08 21:28:41
 
  1 - 10   11 - 20   21 - 30   31 - 40   41 - 47  

  1. PHP OAuth class Post to user's LinkedIn Account   Reply   Report abuse  
Picture of Bill Egan
Bill Egan
2012-12-13 15:48:55
First off, Manuel, thanks for creating and sharing this class. I found it helpful when posting to user's Twitter accounts.

However, I am having trouble doing the same with LinkedIn.
Using the login_with_linkedin.php example I am able to successfully log into the user account using this bit of code that you provided.

$client->scope = 'r_fullprofile r_emailaddress r_network rw_nus';

$success = $client->CallAPI(
'http://api.linkedin.com/v1/people/~',
'GET', array(
'format'=>'json'
), array('FailOnAccessError'=>true), $user);

However I have been unsuccessful at creating the call to CALLAPI when using the Share API, http://developer.linkedin.com/documents/share-api
And the Post Network Update API, http://developer.linkedin.com/documents/post-network-update

The links to the API documentation don't provide PHP/JSON examples. I need help translating their examples into PHP/JSON to create successful calls to CALLAPI.

Thanks

  2. Re: PHP OAuth class Post to user's LinkedIn Account   Reply   Report abuse  
Picture of Bill Egan
Bill Egan
2012-12-13 16:04:58 - In reply to message 1 from Bill Egan
BTW-
Here's my latest attempt for the Post Network Update API

$success = $client->CallAPI(
'http://api.linkedin.com/v1/people/~/person-activities',
'POST', array(
"format"=>"json",
"activity"=>"en_US",
"content-type"=>"linkedin-html",
"body"=>"My Test Update"), array('FailOnAccessError'=>true), $user);

  3. Re: PHP OAuth class Post to user's LinkedIn Account   Reply   Report abuse  
Picture of Bill Egan
Bill Egan
2012-12-17 21:45:45 - In reply to message 2 from Bill Egan
I've decided to focus in on the Error with the Post Share API but have had to no success...

Here is my latest attempt with that:
// SCOPE
$client->scope = 'r_fullprofile r_emailaddress r_network rw_nus';

$success = $client->CallAPI(
'http://api.linkedin.com/v1/people/~/shares',
'POST', array(
"format"=>"json",
"comment"=> "Test"
), array('FailOnAccessError'=>true), $user);


Error Message:
Error: it was not possible to access the API call: it was returned an unexpected response status 401 Response: { "errorCode": 0, "message": "Unknown authentication scheme", "requestId": "Z06IFGQO4C", "status": 401, "timestamp": 1355777206644 }

  4. Re: PHP OAuth class Post to user's LinkedIn Account   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2012-12-19 12:07:32 - In reply to message 3 from Bill Egan
The parameters passed to the API call must be an object like below and the RequestContentType must be set to 'application/json'. You also need to use the latest version of the class, so it does not fail with the response status 201.

$parameters = new stdClass;
$parameters->comment = "Posting from the API using JSON";
$parameters->content = new stdClass;
$parameters->content->title = "A title for your share";
$parameters->content->{'submitted-url'} = "http://www.linkedin.com";
$parameters->content->{'submitted-image-url'} = "http://lnkd.in/Vjc5ec";
$parameters->visibility = new stdClass;
$parameters->visibility->code = 'anyone';
$success = $client->CallAPI(
'http://api.linkedin.com/v1/people/~/shares',
'POST', $parameters, array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);

  5. Re: PHP OAuth class Post to user's LinkedIn Account   Reply   Report abuse  
Picture of Bill Egan
Bill Egan
2012-12-19 22:03:27 - In reply to message 4 from Manuel Lemos
Thanks for taking the time to help, Manuel.

It worked!!

  6. Re: PHP OAuth class Post to user's LinkedIn Account   Reply   Report abuse  
Picture of Rong Rong
Rong Rong
2012-12-24 02:33:02 - In reply to message 4 from Manuel Lemos
Hi, Manuel.
I also use the login_with_linkedin file, it worked, but I want to save the member id and validate it when user login. How should I do that, I have tried many times, it was failure at last, it returned firstName, lastName, headline, siteStandardProfileRequest. How can I get the member id?
Can you hep me? Thanks In Advance.

  7. Re: PHP OAuth class Post to user's LinkedIn Account   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2012-12-26 01:54:51 - In reply to message 6 from Rong Rong
What do you need the member ID for?

When you authenticate an user with OAuth you just need to keep the access_token and the access_token_secret values to send API requests on his behalf.

  8. Re: PHP OAuth class Post to user's LinkedIn Account   Reply   Report abuse  
Picture of Rong Rong
Rong Rong
2012-12-27 10:40:03 - In reply to message 7 from Manuel Lemos
Hi, Manuel.
Thanks for your reply. Because I want to authenticate if the user have registered when they login my web with linkedin.
So, at the first step, when they use linkedin account registered my web, I will save their member id. How can I do that? Thank you!

  9. Re: PHP OAuth class Post to user's LinkedIn Account   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2012-12-27 11:11:41 - In reply to message 8 from Rong Rong
You do not need the LinkedIn user ID for that.

What you need to do is to store the access_token and access_token_secret variables to access the LinkedIn API on behalf of that user, even when the user is not present.

  10. Re: PHP OAuth class Post to user's LinkedIn Account   Reply   Report abuse  
Picture of Arno Buizer
Arno Buizer
2013-01-04 16:54:24 - In reply to message 9 from Manuel Lemos
I am in a similar situation as Rong Rong in message 8.
I want to match something unique in the linkedIn profile of a member with the profile of the member within my website.
For facebook/Google/Twitter i use the id of the member (and I also use the name for me as admin the check this relation.)
Each member that wants to use oath as additional way to login to my website has to connect his 'oath' profile with his profile on my website. Every session after he has made this connection, he gets access to my website when he's logged in on e.g Facebook/Google etc.
However for LinkedIn I don't have a unique ID found in the return data.When trying this with my own LinkedIn account I even do not get my emailadres registered at LinkedIn. This is what I get in the returned data: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<person>
<first-name>my firstname</first-name>
<last-name>my lastname</last-name>
<headline>the name of the company I work</headline>
<site-standard-profile-request>
<url>http://www.linkedin.com/profile?viewProfile=&amp;key= a number&amp;authToken=a token&amp;authType=name&amp;trk=api*a code*another code*</url>
</site-standard-profile-request>
</person>

How do I get these xml fields into fields/variables like in the other examples?
And why isnt my emailadres given in this set of data?
as scope setting I use the one from the example file: $client->scope = 'r_fullprofile r_emailaddress'; which suggests also to get an emailaddress.


 
  1 - 10   11 - 20   21 - 30   31 - 40   41 - 47