2016-12-05 4 views
0

だけページ作成者が、ページの作者せず、それはthis.Myコードのいずれかの解決策を見つけることができませんでした私のpage.Iにメッセージを送信している他の答えを返信されていませんが返信私のFacebookのボットは、以下の通りである:私のFacebookにメッセージを送信しているすべての人が、Facebookのボットで再生しないのはなぜですか?

<?php 
     $challenge = $_REQUEST['hub_challenge']; 
     $verify_token = $_REQUEST['hub_verify_token']; 

     $accessToken = "mytokem is here"; 

     // Set this Verify Token Value on your Facebook App 
     if ($verify_token === 'Verifytoken') { 
     echo $challenge; 
     } 
    $input = json_decode(file_get_contents('php://input'), true); 
    // Get the Senders Graph ID 
    $sender = $input['entry'][0]['messaging'][0]['sender']['id']; 
    // Get the returned message 
    $message = $input['entry'][0]['messaging'][0]['message']['text']; 
    echo $message; 
    //API Url and Access Token, generate this token value on your Facebook App Page 
    $url = 'https://graph.facebook.com/v2.6/me/messages?   access_token='.$accessToken; 
    //Initiate cURL. 
     $ch = curl_init($url); 
    //The JSON data. 
    $jsonData = '{ 
     "recipient":{ 
      "id":"' . $sender . '" 
     }, 
     "message":{ 
      "text":"hello user" 
     } 
     }'; 
     //Tell cURL that we want to send a POST request. 
     curl_setopt($ch, CURLOPT_POST, 1); 
     //Attach our encoded JSON string to the POST fields. 
     curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); 
     //Set the content type to application/json 
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:   application/json')); 
     //Execute the request but first check if the message is not empty. 
     if(!empty($input['entry'][0]['messaging'][0]['message'])){ 
      $result = curl_exec($ch); 
     } 

答えて

0

あなたテストモードでfbのボットアプリ? あなたのfbアプリfacebookで承認されました。 テスト中のアプリであれば、adminまたはtesterだけがbotを使用できます。

ボットが世界に公開される前に、レビュープロセスを経て、誰とでもチャットできる状態にしておく必要があります。

+0

これを行うには、どのようにレビュープロセスに行くのですか? –

+1

あなたのボットが準備ができている場合は、このlnkhttps://blog.hartleybrody.com/fb-messenger-bot/ –

+0

の手順7に従って、fbにレビュー依頼を送信します。fb docs https://developers.facebookから読むことができます.com/docs/messenger-platform/app-review –

関連する問題