mercredi 3 octobre 2018

Why occur error [HTTP/1.0 400 Bad Request content-length: 0 ] using Abraham\TwitterOAuth?

I using lib Abraham\TwitterOAuth at: https://twitteroauth.com/ to send message to Twitter Users:

$consumer_key = env('TWITTER_CONSUMER_KEY', '');
        $consumer_secret =env('TWITTER_CONSUMER_SECRET', '');
        $oauth_token = env('TWITTER_ACCESS_TOKEN', '') ;
        $oauth_token_secret =  env('TWITTER_ACCESS_TOKEN_SECRET', '');

                // Initialize the connection
         $connection = new TwitterOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);


                // Send a direct message
         $data = [ 'event' => [
                        'type' => 'message_create',
                        'message_create' => [
                                'target' => [
                                        'recipient_id' => '168374239'
                                ],
                                'message_data' => [
                                        'text' => 'xin chao dai'
                                ]
                        ]
                ]
        ];  

        $connection->post('direct_messages/events/new ', $data, true);  

But it not working: I try show error in function request of TwitterOAuth.php:

$response = curl_exec($curlHandle);
var_dump($response);exit;

It show error:

string(152) "HTTP/1.0 400 Bad Request content-length: 0 date: Thu, 04 Oct 2018 03:49:24 GMT server: tsa_k x-connection-hash: 23d8ddbf8dccadd936e735b5bb791309 "

Why occur error [HTTP/1.0 400 Bad Request content-length: 0 ] using Abraham\TwitterOAuth?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire