Missing required parameters, includes an invalid parameter value, parameter more than once with LinkedIn API

让人想犯罪 __ 提交于 2019-12-01 00:12:55

You need to add the following header in your cURL POST call to ensure that the values you are passing in the body of your POST are interpreted correctly:

Content-Type: application/x-www-form-urlencoded

For additional info, see http://tools.ietf.org/html/rfc6749#section-4.1.3 for the actual OAuth 2.0 RFC spec.

Use: http_build_query

curl_setopt_array($curl, array(
            CURLOPT_HTTPHEADER => array('Content-Type: application/x-www-form-urlencoded'),
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_URL => 'https://www.linkedin.com/uas/oauth2/accessToken',
            CURLOPT_POST => 1,
            CURLOPT_POSTFIELDS => http_build_query (array(
                client_id => "secret",
                client_secret => "secret",
                grant_type => "authorization_code",
                redirect_uri => "url",
                code => $code
            )),
        ));

I am weirded out by this, but I just had the same problem and when I just moved client id and secret to beginning of the POST array and everything worked. I don't even.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!