使用access_token通过php guzzle发布linkedIn

时间:2016-04-11 12:03:07

标签: php http-post linkedin guzzle

我正在尝试使用LinkedIn Share API通过access token使用PHP GUZZLE在关联链接上发布链接。 以下是我的代码。

    $client = new GuzzleHttp\Client(['base_uri' => 'https://api.linkedin.com']);
    $access_token =  'AQWJ0aksdlfjhadfsjjfksasdfasfdHBIJvTUGa_t_3FvaqZPnrsMACC-JyPvpL2GBANlOMLUBSK8OEyfUl9_VLoxVe4ACBePysj-_WHv1-PP-Q-xas2owrngUtlq9P7Z2o95XUiO-Xhd9y0bm36DX9JXyxW-3jV2uBwP9pLJDC_FRZQ2JiCE';
    $req = $client->request('POST', '/v1/people/~/shares?format=json', [
                'headers'           => ["Authorization: Bearer " . $access_token . "\r\n" . "x-li-format: json\r\n" ],
                'client_id'     => '77g514g0o223322v44',
                        'client_secret' => 'iXadQhy2323jpzPbz7Js',
                'json'      => [ 'json' =>[
                                'comment' => "Check out developer.linkedin.com!",
                                'content' => [
                                        "title" => "LinkedIn Developers Resources",
                                        "description" => "Leverage LinkedIn's APIs to maximize engagement",
                                        "submitted-url" => "https://developer.linkedin.com",  
                                        "submitted-image-url" => "https://example.com/logo.png"
                                        ],
                                'visibility' => ['code' => 'anyone']
                                ]
                            ]
            ]);
    var_dump($req->getStatusCode());

但它总是向我Unauthorized response提供401代码。

我知道,我在某些地方做错了。我出错的任何帮助......

1 个答案:

答案 0 :(得分:1)

下面是代码我如何解决我的问题,希望它也会帮助其他人。

downloadableImageView.requestLayout();