Twitter API Expert Needed
Budget: £10 – £20 GBP
The Job
I have a file that posts to twitter for me using a Chron job. I obtain oauth details from postman and add to the code below.
It works fine for exactly 24 hours and then stops and gives unauthorized message 401.
Script works well and posts as needed however it cuts off after 24 hours and i have to obtain a new signature, timestamp etc using postman and re-add to my code. Not ideal as I would like it automated forever. Need someone who can make this code work so i do not have to edit again. thanks
Here is my code
<?php
$tweet = 'This is a test tweet';
$curl = curl_init();
$text = $tweet;
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.twitter.com/2/tweets',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"text": "'.$text.'"
}',
CURLOPT_HTTPHEADER => array(
'Authorization: OAuth oauth_consumer_key="MYAPIKEY",oauth_token="MYAccessToken",oauth_signature_method="HMAC-SHA1",oauth_timestamp="CREATED TIMESTAMP",oauth_nonce="CREATEDNONCE",oauth_version="1.0",oauth_signature="CREATEDSIGNATURE',
'Cache-Control: no-cache',
'Connection: keep-alive',
'Content-Type: application/json',
'Cookie: guest_id=v1%3A163957956105115349; guest_id_ads=v1%3A163957956105115349; guest_id_marketing=v1%3A163957956105115349; personalization_id="v1_W0cnL/A0dfxMQQXtSzzvdg=="'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
}
?>
thanks
I have a file that posts to twitter for me using a Chron job. I obtain oauth details from postman and add to the code below.
It works fine for exactly 24 hours and then stops and gives unauthorized message 401.
Script works well and posts as needed however it cuts off after 24 hours and i have to obtain a new signature, timestamp etc using postman and re-add to my code. Not ideal as I would like it automated forever. Need someone who can make this code work so i do not have to edit again. thanks
Here is my code
<?php
$tweet = 'This is a test tweet';
$curl = curl_init();
$text = $tweet;
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.twitter.com/2/tweets',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"text": "'.$text.'"
}',
CURLOPT_HTTPHEADER => array(
'Authorization: OAuth oauth_consumer_key="MYAPIKEY",oauth_token="MYAccessToken",oauth_signature_method="HMAC-SHA1",oauth_timestamp="CREATED TIMESTAMP",oauth_nonce="CREATEDNONCE",oauth_version="1.0",oauth_signature="CREATEDSIGNATURE',
'Cache-Control: no-cache',
'Connection: keep-alive',
'Content-Type: application/json',
'Cookie: guest_id=v1%3A163957956105115349; guest_id_ads=v1%3A163957956105115349; guest_id_marketing=v1%3A163957956105115349; personalization_id="v1_W0cnL/A0dfxMQQXtSzzvdg=="'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
}
?>
thanks