ウェブサイトにLINEアカウントでログインする機能を作っています。
困っているところは、公式サイトのドキュメント通りpostしているのにsome parameters missed or invalid というエラーがreturnされていることです。
以下のように書きました。
$post_dataにはちゃんと正しい値が入っていますので、問題なさそうです。
$post_data = [ 'grant_type' => 'authorization_code', 'code' => xxxx, 'client_id' => xxxxx, 'client_secret' => xxxxx, 'redirect_uri' => 'https://xxx.com/users/login_line', ]; $headers[] = "Content-Type: application/x-www-form-urlencoded"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); $result = (array)json_decode($response, true); var_dump($result); exit;
以下のはレスポンス結果です
{"error":"invalid_request","error_description":"some parameters missed or invalid"}array(1) { [0]=> int(1) }
パラメーターが足りないか間違っていると怒られていますが、何が原因か全然わかりません。
回答3件
あなたの回答
tips
プレビュー