Twitter Account Activity Api 214 Error Response

restapi
webhooks

#1

Hi,

My twitter app have access to account activity. and I’m trying to implement Twitter Webhook. When am trying to make post request to account_activity/webhooks am getting this error

stdClass Object
(
    [errors] => Array
        (
            [0] => stdClass Object
                (
                    [code] => 214
                    [message] => Webhook URL does not meet the requirements. Please consult: https://dev.twitter.com/webhooks/securing
                )
        )
)

Here is the request

$result = $twitter->post('account_activity/webhooks', [
    'url' => urlencode('https://api.publicam.in/webhook/twitter.php')
]);

and for CRC Challenge am doing this in PHP

if (isset($_GET['crc_token'])) {
    header('Content-Type: application/json');
    
    $sha256_hash_digest = base64_encode(hash_hmac(
        'sha256', 
        $_GET['crc_token'],
        '<Consumer Secret>'
    ));

    echo json_encode([
        'response_token' => "sha256=$sha256_hash_digest"
    ]);
}

As per Twitter guidelines, output response is
200,
valid json with response_token as output
Latency is below 1 sec

When I try I don’t get any GET request from Twitter for CRC Challenge.


#3

Hi @haridarshan2901 haridarshan2901,

I took a look at your webhook URL and it appears that the latency is currently around 1.6 seconds. I verified this using the following method: https://blog.josephscott.org/2011/10/14/timing-details-with-curl/

Please work to lower your latency to less than 1 second and let me know if you continue to have issues.

Thanks,

-Harrison


#4

Thanks @Harris_0n

Our server is in India (Mumbai region) so can you please me know from which region Twitter is hitting the url so that we can reduce the network hops to reduce the latency


#5

Worst case scenario due to failover, etc is you will be hit from a US West data center. We have data centers strategically placed around the world, but we cannot disclose and I do not have the information of exact regions/locations. I can tell you we do have a few developers operating servers in India without latency issues.


#6

Hi @joncipriano / @Harris_0n ,

I’ve deployed my code on AWS EC2 to reduce the latency but still am getting

stdClass Object
(
    [errors] => Array
        (
            [0] => stdClass Object
                (
                    [code] => 214
                    [message] => Webhook URL does not meet the requirements. Please consult: https://dev.twitter.com/webhooks/securing
                )
        )
)

Here is the url

https://twitterhook.publicam.in/webhook/webhook.php

Pingdom Result (From San Jose, California, USA):


#7

@haridarshan2901, latency looks great! However, the URL isn’t returning a valid JSON response with response token.


#8

@joncipriano , I checked again by directly access the url with get param

https://twitterhook.publicam.in/webhook/twitter.php?crc_token=123

And output am getting is valid json response

{"response_token":"sha256=Zjk4NTY4MmU2ZDRlYmIwYzk5NWNmOGZlOWFjYjFhZWExNDgxNmY2ZTg1ZDA0OGU2ZWY5Mjk4MTg2MDYxMTIyYQ=="}

Another thing is when am making POST request to ‘account_activity/webhooks’ am not getting hit on my server from twitter with crc_token

$result = $twitter->post('account_activity/webhooks', [
    'url' => urlencode('https://twitterhook.publicam.in/webhook/twitter.php')
]);

#9

@Harris_0n / @joncipriano

I’m stuck with this, Kindly help.

Since I’ve deployed it on aws so latency shouldn’t be an issue but if still latency is the issue please let me know and the url is giving valid json response with response_token as output.

But whenever I am making post request am not getting crc_token from Twitter


#10

Your generated response token looks long. Can you share your consumer key? Please don’t share the secret or other access tokens here.


#11

@joncipriano

Here is the Consumer Key: 68QufYuG7vNzUb7rKt67i1Iv8

In php am doing like this to generate the response token

echo json_encode([
	'response_token' => 'sha256='.base64_encode(hash_hmac(
		'sha256', 
		$_GET['crc_token'],
		'<Consumer Secret>'
	))
]);

#12

I hope it’s fine for me to post my issue which is identical to @haridarshan2901’s under this thread. Please pardon me if not, this is my first post in the forums

ISSUE
I’m also trying to create a new webhook like @haridarshan2901

Whenever I use URL: “https://trendsdev.chatdesk.com/twitterData/webhook.json”, I get the 214 error which @haridarshan2901 stated in his post. Also, checking the server logs reveals that there was no CRC validation call from Twitter to the endpoint, which indicates that the issue is not latency.

However, when I use this URL: “https://74a09664.ngrok.io/twitterData/webhook.json” which is a ngrok pointing to the same application on my local computer, using the same consumer key, everything works fine and the webhook is created successfully

App name is “ChatDesk Trends”.

ERROR LOGS
2017-07-19 17:54:50.409: Creating Twitter webhook with URL: https://trendsdev.chatdesk.com/twitterData/webhook.json

twitter4j.TwitterException: 400:The request was invalid. An accompanying error message will explain why. This is the status code will be returned during version 1.0 rate limiting(https://dev.twitter.com/pages/rate-limiting). In API v1.1, a request without authentication is considered invalid and you will get this response.
message - Webhook URL does not meet the requirements. Please consult: https://dev.twitter.com/webhooks/securing
code - 214


Invalid response token
#13

@joncipriano

I got it working. Documentation says the url should be url encoded but it worked when i sent it raw url instead of encoded url.


#14

Hi Haridarshan,
I am Remya…
Can you help me to implement account activity api in my site…
While I am trying this I am getting an error message Error :32 , could not authenticate you.
I am stuck with this…
please…

Regards,

Remya


#15

Hi Remya,

Is your twitter app authorized for account activity. If not then first get it approved from Twitter. Here is the link for the form


#16

Hi Hari,

Thank you for your reply. I have submitted that form at 29th September. How long will it take to approve…?


Account Activity API: Got Error Message
#17

We’re onboarding new developers to the beta API gradually, and review the applications a couple of times a week. We appreciate your patience. Thanks!


#18

Try base64_encode(hash_hmac('sha256', $_GET['crc_token'], '<Consumer Secret>', TRUE)
PHP hash_hmac() is return string, But Python hmac.new() is return bytes


#19

HI @haridarshan2901, I am getting below error while registering webhook url.
[{“code”:261,“message”:"Application cannot perform write actions. Contact Twitter Platform Operations through https://support.twitter.com/forms/platform."}]

My app is approved for Beta activities.

Consumer key is: BPntVVFQDCBjl7WPSoyhYFW16

Can somebody help me?