无法通过 API 发布到LinkedIn


Can't post to LinkedIn via API

这是我的代码:

 $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);

但没有效果。https://apigee.com/console/linkedin 尝试了这项服务 - 效果很好...

怎么了?

你想构建什么? JSSDK可以做得更好!看看我开发的这个工具:

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

和源代码:

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

如果可以的话,你的项目以此为基础。