ThongTran-Dev / simple-linkedinphp

Automatically exported from code.google.com/p/simple-linkedinphp
0 stars 0 forks source link

when using share function always get 401. Get is working ok. Post - not. #16

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Folloing you example to post to linkedin
2.
3.

What is the expected output? What do you see instead?
I am gettin: 401 [unauthorized]. Same authorization with GET method is working 
fine.

What version of the product are you using? On what operating system?
lates: 3.3.0

Please provide any additional information below.

Try it the demo on your page. same error. Can you post a fix??? thank you in 
advanced

Original issue reported on code.google.com by div...@gmail.com on 2 Jan 2012 at 9:45

GoogleCodeExporter commented 9 years ago
i keep getting this too... even tough content-type is clearly given. But it 
might be the order in which the request header is made up. Here's my request 
object:

OAuthRequest Object
(
[parameters:protected] => Array
(
[oauth_version] => 1.0
[oauth_nonce] => f7cb6f82764aa681a61e48a6dd900aae
[oauth_timestamp] => 1324992275
[oauth_consumer_key] => [MY KEY]
[oauth_token] => Token
[Content-Type] => text/xml
[oauth_signature_method] => HMAC-SHA1
[oauth_signature] => CkjbP9b1V06sf4C29Uy4RYZrCRk=
)

[http_method:protected] => POST
[http_url:protected] => 
https://api.linkedin.com/v1/posts/g-4219968-S-86139449/comments
[base_string] => 
POST&https%3A%2F%2Fapi.linkedin.com%2Fv1%2Fposts%2Fg-4219968-S-86139449%2Fcommen
ts&Content-Type%3Dtext%252Fxml%26oauth_consumer_key%KEY%26oauth_nonce%3Df7cb6f82
764aa681a61e48a6dd900aae%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%
3D1324992275%26oauth_token%3D475d8604-8e79-4071-a007-8218636bfb33%26oauth_versio
n%3D1.0
)

And this is the error:

Array
(
[linkedin] => <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
<status>401</status>
<timestamp>1324992276325</timestamp>
<request-id>FYEGMNDBNP</request-id>
<error-code>0</error-code>
<message>[unauthorized]. 
OAU:31vn2yyqkpzq|475d8604-8e79-4071-a007-8218636bfb33|*01|*01:1324992275:CkjbP9b
1V06sf4C29Uy4RYZrCRk=</message>
</error>

Original comment by Luc.Prin...@gmail.com on 4 Jan 2012 at 11:38

GoogleCodeExporter commented 9 years ago
Guys, you can fix this issue by modifying the fetch method in the linkedin 
class. You just need to set the headers correctly. add the following code:

$header[] = 'Content-Type: text/xml; charset=UTF-8';

before the headers are set by the call curl_setopt($handle, CURLOPT_HTTPHEADER, 
$header); 

Good luck!

Original comment by douglas....@gmail.com on 18 Jan 2012 at 9:32

GoogleCodeExporter commented 9 years ago
Holy damn shit! You just saved my life! :)

It works! Finally! Thanks!

Original comment by Luc.Prin...@gmail.com on 18 Jan 2012 at 10:18

GoogleCodeExporter commented 9 years ago
For the people who are having trouble with this, i've posted the fix on 
pastie.org...
at the fetch() function, (line 822) there's an if-statement: if ( is_null( 
$data ) ), change that
condition with this:

http://pastie.org/3217683

Original comment by Luc.Prin...@gmail.com on 20 Jan 2012 at 7:36