PHP Classes

the access token is not set to a valid value

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  How to Implement PHP ...  >  All threads  >  the access token is not set to a...  >  (Un) Subscribe thread alerts  
Subject:the access token is not set to a...
Summary:linkedin post a job can't get a token
Messages:5
Author:allenmao
Date:2015-04-29 05:53:04
 

  1. the access token is not set to a...   Reply   Report abuse  
Picture of allenmao allenmao - 2015-04-29 05:53:04
<?php

require('http.php');
require('oauth_client.php');
// 2 legged without user's presentation
$jobURL = 'https://api.linkedin.com/v1/jobs';
$xml = file_get_contents('job.xml');

$client = new oauth_client_class;
$client->debug = true;
$client->debug_http = true;
$client->server = '';
$client->signature_method = 'HMAC-SHA1';

$client->client_id = 'xxxxxxxxxxxxxx';
$client->client_secret = 'xxxxxxxxxxxxxxxx';

$client->request_token_url = $jobURL;
$client->access_token_url = $jobURL;

$client->oauth_version = '1.0';

$client->dialog_url = 'automatic';
$client->token_request_method = 'POST';

// API permission scopes
$client->scope = 'r_basicprofile rw_nus w_messages';
$client->access_token_authentication = 'basic';


if(($success = $client->Initialize()))
{

if(($success = $client->Process()))
{

$success = $client->CallAPI(
$jobURL,
'POST',
array(''),
array('FailOnAccessError'=>true,'2Legged'=>true,'RequestContentType'=>'application/xml','RequestBody'=>$xml),
$result);



if(strlen($client->access_token))
{

/*
$success = $client->CallAPI(
$jobURL,
'POST', array(
'media[]'=>'newjob.xml'
), array('FailOnAccessError'=>true,'2Legged'=>true,
'Files'=>array('media[]'=>array('ContentType'=>'application/xml'))),
$result);
*/
}
}
$success = $client->Finalize($success);
}
echo 'error: '.HtmlSpecialChars($client->error);

if($client->exit)
exit;


  2. Re: the access token is not set to a...   Reply   Report abuse  
Picture of allenmao allenmao - 2015-04-29 07:07:41 - In reply to message 1 from allenmao
fixed by customize the http.php

removed form-data, boundry.etc
and changed to application/xml

  3. Re: the access token is not set to a...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-04-29 08:05:10 - In reply to message 1 from allenmao
There was a bug in the 2 legged implementation that was requiring a valid access token.

I just uploaded a fixed version but you should not call the Process function when making only 2 legged requests.

  4. Re: the access token is not set to a...   Reply   Report abuse  
Picture of allenmao allenmao - 2015-04-29 08:18:03 - In reply to message 3 from Manuel Lemos
meaning 2 legged request do not need a valid access token,
am i correct?

  5. Re: the access token is not set to a...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-04-29 08:27:10 - In reply to message 4 from allenmao
Yes, the access token is only necessary if you need user permissions, which is not the case of 2 legged requests.