I am using this LinkedIn plugins for CakePHP 2.0.4: https://github.com/ProLoser/CakePHP-LinkedIn
I setup everything to work fine with login and get user's profiles like first name, last name,... using this syntax: $this->Linkedin->find("all",...). I renamed the default name,"Linkedin", of Linkedin datasource to "LinkedinSource", hence I can call my model "Linkedin" just for my convenience.
I followed the file /Plugin/Linkedin/Model/LinkedinMessage.php to create this function in my Linkedin model:
function updateStatus($message) {
$request = $this->request;
$request['uri']['path'] = 'people/~/shares';
$this->request = $request;
//Above 3 lines are used to bypass the error "changing value of overloaded object property has no effect if I use $this->request["uri"]["path"] = "..."
$data = array(
'comment' => $message
, 'visibility' => array('code' => 'anyone')
);
//Above settings follow this: https://developer.linkedin.com/documents/share-api
$saved = $this->save($data);
}
When I run above code using my own LinkedIn account (connected & authorized), the value of $saved is just TRUE but NO status/share is posted to my LinkedIn account when I open my account on a browser (Google Chrome)
I tried to change the URI Path to
$request['uri']['path'] = 'people/~/person-activities';
and request data to:
$data = array(
'content-type' => "linkedin-html"
, 'body' => $message
);
as in https://developer.linkedin.com/documents/post-network-update but still no better result.
I also change these lines in /Plugin/Linkedin/Config/LinkedinSource.php:
$config['Apis']['LinkedinSource']['write'] = array(
// http://developer.linkedin.com/docs/DOC-1044
'mailbox' => array(
'people/~/mailbox' => array(
'subject',
'body',
'recipients',
),
),
);
to
$config['Apis']['LinkedinSource']['write'] = array(
// http://developer.linkedin.com/docs/DOC-1044
'mailbox' => array(
'people/~/mailbox' => array(
'subject',
'body',
'recipients',
),
),
//https://developer.linkedin.com/documents/share-api
'shares' => array(
'people/~/shares' => array(
'comment',
'content',
'visibility',
),
),
);
but still no better result.
Just be noted I added these lines in /Plugin/Linkedin/Model/LinkedinMessage.php
public $startQuote;
public $endQuote;
to avoid these errors:
Undefined property: LinkedinSource::$startQuote [CORE/Cake/Model/Model.php, line 1269]
Undefined property: LinkedinSource::$endQuote [CORE/Cake/Model/Model.php, line 1269]
I dont know if that can cause my problem or not but I want to list all details here.
Please help as I spent almost one day to make this work but still can not :(
Found the problem! The Content-Type MUST be application/json in order to work! I thought x-li-format: json is enough but it is NOT.