facebookのMessengerプラットフォームを利用し、
webhookから取得したpsid に対し、次のようにメッセージを返しています。
$tokenはMessengerプラットフォームのトークン生成から取得したものとなります。
$token = "xxxxxxxxx....."; $data = [ "messaging_type" => "RESPONSE", "recipient" => [ 'id' => "$psid", ], "messages" => [ 'text' => "hogehge", ], ]; $res = json_encode($data); $url = "https://graph.facebook.com/v2.6/me/messages?access_token=$token"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', ]); curl_setopt($ch, CURLOPT_POSTFIELDS, $res); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $response = curl_exec($ch); curl_close($ch);
この結果、以下のエラーメッセージが戻ってくるのですが、送信APIの認証などが漏れていたりするものなのでしょうか。。
ご存知の方、アドバイスをいただけますと幸いです。
{"error":{"message":"(#100) Must send either message or state","type":"OAuthException","code":100,"error_subcode":2018015,"fbtrace_id":"G3oPdOXXXXX"}}
どうぞ、よろしくお願い申し上げます。
回答1件
あなたの回答
tips
プレビュー