I can not receive events in my webhook (it's empty)



I have managed to register my webhook url
POST https://api.twitter.com/1.1/account_activity/all/:env_name/webhooks.json

I have also been able to add subscribers
POST https://api.twitter.com/1.1/account_activity/all/:env_name/subscriptions.json

I have verified challenge response (CRC)
PUT https://api.twitter.com/1.1/account_activity/all/:env_name/webhooks/:webhook_id.json

I have activities in my account as: (Tweets, Retweets, @mentions, Favorite (like), Direct message).
The account activities reach my email but empty.
Example: Test [ ]

This is my code in the webhook to receive email


  $headers = apache_request_headers();

  $input_txt = file_get_contents('php://input');
  $input_txt = json_decode($input_txt);

  function send_email_twitter_activity($from_email,$to_email,$subject,$body)

    $mailgun_url='URL email';

    $array_data = array(
      'from'=> $from,

    $session = curl_init($mailgun_url);
      curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
      curl_setopt($session, CURLOPT_USERPWD, $mailgun_key);
      curl_setopt($session, CURLOPT_POST, true);
      curl_setopt($session, CURLOPT_POSTFIELDS, $array_data);
      curl_setopt($session, CURLOPT_HEADER, false);
      curl_setopt($session, CURLOPT_ENCODING, 'UTF-8');
      curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
    $response = curl_exec($session);

    $results = $response;
    return $results;


  $token  = $_REQUEST['crc_token'];
  $res    = $_REQUEST;
  $res = json_encode($res);

  send_email_twitter_activity("juan@hotmail.com","juan215@hotmail.com","Datos recibidos Profile","Test: $res");

  function get_challenge_response($token) {
    $hash = hash_hmac('sha256', $token, $APP_CONSUMER_SECRET, true);
    $response = array(
      'response_token' => 'sha256=' . base64_encode($hash)
    header("HTTP/1.1 200 OK");
    header('Content-Type: application/json;charset=utf-8');
    return json_encode($response);

  // // prints result
  echo  get_challenge_response($token);


closed #2

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

opened #3


Hi Juan - did you manage to get this sorted out?


Thanks for asking.
Yes, I already managed to solve the problem, I just needed these lines of code to work correctly.

$token = $_GET['crc_token'];

$input_txt = file_get_contents('php://input');
$input_txt = json_decode($input_txt,true);


closed #6