-1

here is my code:

 $url = 'https://api.linkedin.com/v1/people/~/shares?oauth2_access_token=XXXXXXX';
$url .= '&format=json';

    $postdata = http_build_query(
                                 array(
                                        'comment' => 'comment',
                                        'content' => array('title' => 'LInkedIN title',
                                                        'description' => 'linkedin desc',
                                                        'submitted-url' => "https://developer.linkedin.com",
                                                            ),

                                        'visibility' => array('code' => 'anyone')
                                    )
                                );

    $opts =     array('http' =>
                                            array('method' => 'POST',

                                            'header'=> "x-li-format : json\r\n".
                                            "Host: api.linkedin.com\r\n".
                                            "Content-Length: ".strlen($postdata)."\r\n".
                                            "X-Target-URI: https://api.linkedin.com\r\n".
                                            "Content-Type: application/json\r\n".
                                            "Connection: Keep-Alive",

                                            'content' => $postdata

                                            )                           
                                        );

$context = stream_context_create($opts);
$result = file_get_contents($url, false, $context);

but there is no effect. Tried this service https://apigee.com/console/linkedin - works perfectly...

What's wrong?

Igor
  • 11
  • 2

1 Answers1

0

what are you trying to build? the jssdk can do this much better! Check out this tool I developed:

http://datopstech.com/linkedin-share-tool/

and the source code:

https://github.com/kaburkett/LinkedIn-Advanced-Share

And base your project off that if you can.

Kyle Burkett
  • 1,375
  • 12
  • 28