正确获取CURL帖子参数(PHP)

I'm trying to send a post request to the linkedin API using CURL. For some reason I get a response saying that I'm missing one variable.

array:2 [▼
  "error" => "missing_parameter"
  "error_description" => "A required parameter "client_id" is missing"
]

Here is my code and I can assure you that cliend_id is set.

    $code = $request->get("code");
    $state = $request->get("state");
    $redirect_uri = "http://example.com/linkedin/callback";
    $client_id = "1242435657";
    $client_secret = "XXXXXXXXXX";

    $url = "https://www.linkedin.com/oauth/v2/accessToken";

    $params = array(
        "grant_type" => 'authorization_code',
        "code" => $code,
        "redirect_uri" => $redirect_uri,
        "client_id" => $client_id,
        "client_secret" => $client_key,
    );

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, true);

    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
    $output = curl_exec($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);

    // create an array from the data that is sent back from the API
    $result = json_decode($output, 1);  

Is there anyway that I could debug this post request?

Remove the comma at the end of the last property and try again perhaps?

$params = array(
        "grant_type" => 'authorization_code',
        "code" => $code,
        "redirect_uri" => $redirect_uri,
        "client_id" => $client_id,
        "client_secret" => $client_key, <=========
    );