Login   Register  
PHP Classes
elePHPant
Icontem

OAuth Linkedin GET network updates

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  >  OAuth Linkedin GET network updates  >  (Un) Subscribe thread alerts  
Subject:OAuth Linkedin GET network updates
Summary:OAuth Linkedin GET network updates
Messages:6
Author:Xavier
Date:2013-03-20 16:41:19
Update:2013-03-25 15:34:43
 

  1. OAuth Linkedin GET network updates   Reply   Report abuse  
Picture of Xavier
Xavier
2013-03-20 16:41:20
Hi, I'm working with the Linkedin API, and I want to get my network updates.

I succeeded it by installing the pecl package OAuth. But it seems more convenient to use your library instead of installing pecl package on servers. Your work is great, but I have some issues to make it. I have the same problem on the topic http://www.phpclasses.org/discuss/package/7700/thread/38/ for Linkedin Groups.

This is what I have:

Array
(
[errorCode] => 0
[message] => Access to network denied
[requestId] => 2YIJKY504Y
[status] => 403
[timestamp] => 1363793092035
)

In the linkedin groups topic, you say that "You need to restart the process to obtain a new token with the right permissions." The thing is, here is my code:

$this->oauth = new oauth_client_class;
$this->oauth->debug = 1;
$this->oauth->debug_http = true;
$this->oauth->server = 'LinkedIn';
$this->oauth->redirect_uri = $this->redirectURL;
$this->oauth->client_id = $this->apiKey;
$this->oauth->client_secret = $this->secretKey;
$this->oauth->access_token = $this->accessToken;
$this->oauth->access_token_secret = $this->secretToken;
$this->oauth->scope = $this->scope;

public function getInfos() {

if(($success = $this->oauth->Initialize())) {
if(($success = $this->oauth->Process())) {
if(strlen($this->oauth->access_token)) {

$success = $this->oauth->CallAPI(
'http://api.linkedin.com/v1/people/~/network/updates?type=SHAR',
'GET',
array(
'oauth_access_token' => $this->accessToken,
'oauth_callback' => $this->redirectURL,
'scope' => $this->scope,
'format'=>'json'
),
array(
'FailOnAccessError'=>true,
'ConvertObjects' => true,
'Type' => 'Data'
),
$user
);
}
}
$success = $this->oauth->Finalize($success);
print_r($user);
}
As you can see, it's quite the same that your login_with_linkedin tutorial.
I don't get it because I make the process function. But I just keeping the 403 status.
Can you explain what I do wrong? By the way, my scope is $scope = "r_network rw_nus";

Thank you very much.

  2. Re: OAuth Linkedin GET network updates   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2013-03-20 22:46:45 - In reply to message 1 from Xavier
Do not set the access_token and access_token_secret variables before going through the authorization process, otherwise the class assumes the values in those variables are valid and the authorization process does not happen.

  3. Re: OAuth Linkedin GET network updates   Reply   Report abuse  
Picture of Xavier
Xavier
2013-03-21 02:47:19 - In reply to message 2 from Manuel Lemos
Hi, thanks for reply!
But I still have trouble about this.
I don't understand about not setting the access_token and access_token_secret before the Process function. If I don't set those, the process just don't happen. It can't pass through the function and can't get to the CallApi function.
Are you talking about the Process function? I'm sure there is something I don't understand, but I just don't know what.


  4. Re: OAuth Linkedin GET network updates   Reply   Report abuse  
Picture of Xavier
Xavier
2013-03-21 03:37:46 - In reply to message 3 from Xavier
Ok, I succeed in order to get the network updates. I made what you said and worked with the $_SESSION['OAUTH_ACCESS_TOKEN'] variables. But I don't think it's the right method.

And the problem is that they asked manually for authentification (by the authentification page), the thing is that can't have that, I need the content without manually authentification.

Here is my code, but I don't think it's the good way to do it. And moreover, what do I pass to the $parameters values?

public function getInfosTest($type, $method) {

if(($success = $this->oauth->Initialize()))
{
if(($success = $this->oauth->Process()))
{
if(strlen($_SESSION['OAUTH_ACCESS_TOKEN']['https://api.linkedin.com/uas/oauth/accessToken']['value']))
{
$success = $this->oauth->CallAPI(
'http://api.linkedin.com/v1/people/~/network/updates?type=SHAR',
'GET',
array(
'oauth_access_token' => $_SESSION['OAUTH_ACCESS_TOKEN']['https://api.linkedin.com/uas/oauth/accessToken']['value'],
'oauth_secret_token' => $_SESSION['OAUTH_ACCESS_TOKEN']['https://api.linkedin.com/uas/oauth/accessToken']['secret'],
'scope' => $this->scope,
'format'=>'json',
),
array(
'FailOnAccessError'=>true,
'ConvertObjects' => true,
'Type' => 'Data'
),
$user
);
}
}
$success = $this->oauth->Finalize($success);
}

if($this->oauth->exit)
exit;
if(strlen($this->oauth->authorization_error))
{
$this->oauth->error = $this->oauth->authorization_error;
$success = false;
}
print_r($user);
}

Thank again.

Xavier

  5. Re: OAuth Linkedin GET network updates   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2013-03-21 04:08:35 - In reply to message 4 from Xavier
The Process function is precisely to go through the authentication process when the user is present.

If you want to call the API when the user is not present, you should not call the Process function.

You can set the access_token and access_token_secret variables directly.

You can also leave the variables empty and the class will call the GetAccessToken to get the token values, but you need to create a sub-class and implement the GetAccessToken and StoreAccessToken functions to store and retrieve token values in a database or somewhere else, not in sessions because PHP sessions only exist when the user is accessing a Web page.

  6. Re: OAuth Linkedin GET network updates   Reply   Report abuse  
Picture of Xavier
Xavier
2013-03-25 15:34:43 - In reply to message 5 from Manuel Lemos
Thank you for your time, it works perfectly. I don't really know what I changed, but by revoke the linkedin key, all finally worked! :)

Again, thank you for your work and your help.