We’ve set up a webhook to put together a simple bot on our own account. The webhook has been secured, registered, and the owner account has been subscribed to it.

We’re seeing the webhook recieving requests for different actions (@mentions, posting, deleting posts), but the requests come through empty—no body, post info, or any other data/payload. The $_POST array is empty. We were expecting to receive data objects as a payload, but aren’t finding any.

Is this common? Are we missing a setup parameter somewhere or is the service down? What can we do to debug the issue?

Thanks!

does the example work? GitHub - twitterdev/account-activity-dashboard: Sample web app and helper scripts to get started with the premium Account Activity API

If so, it may be an issue with how PHP is reading data - that depends entirely on how you coded the part that receives data, or what library you’re using.

Also, blank lines are sent as keepalive signals - these can be ignored - but you should be receiving payloads of objects.

I got the example to run and it does appear to be getting data from the activity requests. So presumably they were getting sent to our php app as well. I guess this ends up being more a php question then, but where should we be looking for this data? It doesn’t appear to be in the request body or added as a POST var.

As far as i remember from php, $_POST will only contain form data - while a webhook is a live, open connection - so depending on how you coded it, it may require reading from php://input and decoding json from the raw responses yourself - i found this but didn’t try the example - maybe that will help? GitHub - sadaimudiNaadhar/php-twitter-webhook-account-activity-api: A Simple PHP Support for Twitter Webhook implementation & Account Activity API subscription.

I guess this shows my php ignorance (I come from front-end development), but, yes, reading streams is different. For posterity, it requires reading from php:// input (e.g. $requestData = file_get_contents('php://input');).

Sadly, I saw someone respond with that answer in the other thread about empty payloads, but as I was unfamiliar with the syntax and the OP never responded to confirm the fix for them, I didn’t even give it a try. So apologies for the duplicate post!

2 Likes

Ah, you got there moments before I did :sweat_smile:

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