php - My page won't answer the Messenger call -
i'm developing code answers via facebook messenger , use piece of code handle answer , answer back:
if(isset($_request['hub_verify_token'])) { if ($_request['hub_verify_token'] === a::verify_token) { echo $_request['hub_challenge']; exit; } } $input = json_decode(file_get_contents('php://input'), true); $sender_id = $input['entry'][0]['messaging'][0]['sender']['id']; $message_text = $input['entry'][0]['messaging'][0]['message']['text']; $fb_handler = new fbhandler($sender_id); /*$to_send = array( 'recipient' => array('id' => $sender_id ), 'message' => array('text' => "hi" ) );*/ $to_send = $fb_handler->talk($message_text); $ch = curl_init('https://graph.facebook.com/v2.6/me/messages?access_token='.a::access_token); curl_setopt_array($ch, array( curlopt_postfields => json_encode($to_send), curlopt_returntransfer => 1, curlopt_httpheader => array('content-type: application/json') )); $response = curl_exec($ch); error_log($response['error']); curl_close($ch);
what don't understand why commented $to_send
works non-commented not, because code in a
class correct, composes correctly array.
so came idea , i'm asking if it's correct (because found nothing in facebook developers documentation): possible array sent messenger has composed in same set of instructions?
i know sounds ridiculous, dunno else think.
also noticed error_log
doesn't work: nothing has been written in php_errorlog
file. what's happening?
Comments
Post a Comment