|
Manuel Lemos - 2013-12-20 16:01:34 - In reply to message 40 from Vlado Nikolchev
In the end it says it is redirecting to LinkedIn site. Did it redirect?
It also says "Resetting the access token status". Are you calling ResetAccessToken function anywhere in your script? You shouldn't because this makes the class "forget the tokens and any other information about the authorization process.
Vlado Nikolchev - 2014-01-03 12:29:00 - In reply to message 41 from Manuel Lemos
Manuel,
First: Happy New Year! And thank you for your support.
I have commented the code that resets the status. Here is my code:
Once again: I'm trying to publish company share on behalf of my company. I am administrator of this company.
============================
$api_url = "http://api.linkedin.com/v1/companies/{id-of-my-company}/shares";
$parameters = new stdClass();
$parameters->comment = 'Some comment';
$parameters->content = new stdClass();
$parameters->content->title = 'Some title';
$parameters->content->description = 'Some description';
$parameters->content->{'submitted-url'} = 'http...';
$parameters->visibility = new stdClass();
$parameters->visibility->code = 'anyone';
$client = new oauth_client_class;
$client->debug = 1;
$client->debug_http = 1;
$client->server = 'LinkedIn';
$client->client_id = 'xxxxxxxxxxxxxxx'; // Taken from my profile
$client->client_secret = 'yyyyyyyyyyyyyyyyy'; // Taken from my profile
$client->scope = 'rw_nus';
if (($success = $client->Initialize())) {
if (($success = $client->Process())) {
if (strlen($client->access_token)) {
$success = $client->CallAPI(
$api_url, 'POST', $parameters, array(
'FailOnAccessError' => true,
'RequestContentType' => 'application/json'
)
);
}
}
$success = $client->Finalize($success);
}
if ($success) {
// ...
} else {
echo $client->error . "\n"
}
==============================
Here is the log:
==============================
OAuth client: Checking the OAuth token authorization state, referer: {our url here}
OAuth client: The OAuth access token is not set, referer: {our url here}
OAuth client: Requesting the unauthorized OAuth token, referer: {our url here}
OAuth client: Accessing the OAuth request token at https://api.linkedin.com/uas/oauth/requestToken?scope=rw_nus, referer: {our url here}
Connecting to api.linkedin.com, referer: {our url here}
Resolving HTTP server domain "api.linkedin.com"..., referer: {our url here}
Connecting to HTTP server IP 216.52.242.83 port 443..., referer: {our url here}
Connected to api.linkedin.com, referer: {our url here}
C GET /uas/oauth/requestToken?scope=rw_nus HTTP/1.1, referer: {our url here}
C Host: api.linkedin.com, referer: {our url here}
C User-Agent: PHP-OAuth-API (http://www.phpclasses.org/oauth-api $Revision: 1.74 $), referer: {our url here}
C Accept: */*, referer: {our url here}
C Authorization: OAuth oauth_consumer_key="{key}",oauth_nonce="449b5e99eac399e566be0fad2a19a002",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1388751014",oauth_version="1.0",oauth_callback="{callback_script}",oauth_signature="{signature}", referer: {our url here}
C Connection: Keep-Alive, referer: {our url here}
C , referer: {our url here}
S HTTP/1.1 200 OK, referer: {our url here}
S Server: Apache-Coyote/1.1, referer: {our url here}
S X-LI-UUID: {UUID}, referer: {our url here}
S Content-Type: text/plain, referer: {our url here}
S Content-Length: 240, referer: {our url here}
S Vary: Accept-Encoding, referer: {our url here}
S Date: Fri, 03 Jan 2014 12:10:14 GMT, referer: {our url here}
S X-Li-Fabric: PROD-ELA4, referer: {our url here}
S Connection: keep-alive, referer: {our url here}
S X-Li-Pop: PROD-ELA4, referer: {our url here}
S , referer: {our url here}
S oauth_token={token}&oauth_token_secret={secret}&oauth_callback_confirmed=true&xoauth_request_auth_url=https%3A%2F%2Fapi.linkedin.com%2Fuas%2Foauth%2Fauthorize&oauth_expires_in=599, referer: {our url here}
Keeping the connection alive to api.linkedin.com, referer: {our url here}
OAuth client: Redirecting to OAuth authorize page https://api.linkedin.com/uas/oauth/authenticate?oauth_token={token}, referer: {our url here}
=======================================
It does not publish to LinkedIn. What could be wrong?
Thank you for your support.
Manuel Lemos - 2014-01-04 02:16:14 - In reply to message 42 from Vlado Nikolchev
As you may see in the last line, it says it is redirecting to LinkedIn, so the user gives your application permission to access to LinkedIn API on his behalf.
Does the browser redirect to LinkedIn permission page? If not, your script is doing something to prevent the redirection of the browser.
Vlado Nikolchev - 2014-01-06 16:14:36 - In reply to message 43 from Manuel Lemos
Manuel, I am trying to create a new post to LinkedIn on behalf of my company (post with a company logo on the left, title, short description and link to our website to the whole story). I don't want to redirect the user. The user just pushes a button (on our website CMS)and this action should post some data to LinkedIn and create an update there. No redirects at all.
Manuel Lemos - 2014-01-06 20:40:43 - In reply to message 44 from Vlado Nikolchev
Yes, but first the user needs to give permission for your application to do that.
The way the OAuth protocol works, is that you need to redirect the user to a specific page of LinkedIn with certain parameters. The user is informed about the permissions you need and if he agrees, LinkedIn redirects the user back to your site passing some tokens for your site to complete the protocol steps.
The OAuth client class simplifies the passing of information back and forth LinkedIn, but the redirection to the authorization page is mandatory. You cannot do anything with the user permission.
In your case the user is your company profile administrator, but the authorization step still must happen.
So you need to make sure the redirect happens at least once.
If the token expires or is revoked for some other reason, you need to repeat the process.
Read this article to understand better the details:
phpclasses.org/blog/package/7700/po ...
Vlado Nikolchev - 2014-01-08 12:32:01 - In reply to message 45 from Manuel Lemos
OK, I read the article and as long as I understand all the steps were passed in my script. I authenticate with all the permissions and pass the variables (title, description..). It does not return an error but does not publish the update as well. What may I miss? Does the API expect additional calls? It looks like the API expects something more?
Manuel Lemos - 2014-01-08 21:28:41 - In reply to message 46 from Vlado Nikolchev
If you proceeded past the redirect, you need to post the new log again, so I can advise.
You may as well check the authentication_error and access_error variables.
Prudhvi Nag B - 2014-12-09 06:21:57 - In reply to message 4 from Manuel Lemos
Hey Manuel,
Is there any sample code in php for posting sharing in linkedin?
Here , what is the $user and $client and can you give callApi() method.?
Thanks in advance,
Manuel Lemos - 2014-12-09 15:34:57 - In reply to message 48 from Prudhvi Nag B
Just use the API URLs of the LinkedIn API documentation you want to call.
thirupathi reddy - 2014-12-11 09:50:36 - In reply to message 14 from Arno Buizer
hai Sir,how to share message UniqueLinkedInID find and save in linkedin api.plz tell me sir.
conrepdevhyd@gmail.com
|