The following is the code which I am calling for registering the webhooks for account activity. I am using the PHP version of TwitterOAuth Apis. The webhook url is a proper https url.

$postRequest = "account_activity/all/".AIRCAST_WEBHOOK_ENV."/webhooks";
$connection = new TwitterOAuth(AIRCAST_CONSUMER_KEY,
                                                AIRCAST_CONSUMER_SECRET,
                                                 AIRCAST_ACCESS_TOKEN,
                                                 AIRCAST_ACCESS_TOKEN_SECRET);

$this->response = $connection->post($postRequest ,["url" => AIRCAST_WEBHOOK_URL]);

Given below is the code for challenge response:

$crc_token = $_GET['crc_token'];
$signature = hash_hmac('sha256', $crc_token, AIRCAST_CONSUMER_SECRET, true);
$response = array ('response_token' => 'sha256='.base64_encode($signature));
echo json_encode($response);

I actually captured the response code too which is in the following format:

{"response_token":"sha256=w3rCkGny3ZP34K+mlYJTK69P1DkF1gY3ETs6NK2q8Aw="}

But no matter what I try I continue to get the CRC token error. Appreciate if you could point to me what exactly is going wrong here. Infact I think, I am getting a proper token too. Thanks.

PS: Infact, I have regenerated the tokens atleast twice.

1 Like

Thanks for reaching out here. You may want to try double-checking your white-space and try changing your single-quotes to double-quotes.

You may also want to consider using an OAuth library (example), one of our GitHub repositories (account-activity-dashboard or twitter-webhook-boilerplate-node), using Insomnia, or try using Twurl.

Hope this helps.

Jessica

2 Likes

Checked for white-space. I did not find anything. Infact I am using Abraham’s OAuth library. But the behavior is the same. We have our whole system in PHP, so the migration to the new framework is close to impossible. Can you just point me as to where else I could be going wrong ?
You mentioned the white-space. Where exactly do you think that the white might exist ?

2 Likes

Could you post a proper error message for this ? It is really frustrating for a developer spending time on this for more than a day.

2 Likes

Did you also register your webhook as well?

Here is some code I found in PHP which may help:

/* Create a TwitterOauth object with consumer/user tokens. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
$url = "Your Webhook URL";
$content = $connection->post("account_activity/all/your-env_name/webhooks", ["url" => $url]);

Others have posted this tutorial which may be helpful here.

1 Like

This is exactly what I did

$postRequest = "account_activity/all/".AIRCAST_WEBHOOK_ENV."/webhooks";
        $connection = new TwitterOAuth(AIRCAST_CONSUMER_KEY,
                                                AIRCAST_CONSUMER_SECRET,
                                                 AIRCAST_ACCESS_TOKEN,
                                                 AIRCAST_ACCESS_TOKEN_SECRET);
       
        $this->response = $connection->post($postRequest ,["url" => AIRCAST_WEBHOOK_URL]);

Infact I followed the same tutorial as mentioned by you.

Is there anything I am missing here ? I even checked the development environment. I have specified the webhook environment in the app settings page too.

I tested the credentials by calling the other apis like the user timeline or the mentions. It works perfectly well, which means there are no unwanted white spaces in the credentials which I am using.

what’s the exact webhook url you’re using? Does it support TLS 1.2?

Yes, TLS1.2 is supported. The URL is : https://roomplayer.in/twitterhook/v10/webhook/callback

Can somebody from twitter answer this ? It has become a showstopper and am unable to proceed further. Appreciate if you can point me to the solution.

Does https://github.com/twitterdev/account-activity-dashboard work? if so, it may narrow down the issue

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