Page 1 of 1

TweetWX script updated for Twitter API V1.1

Posted: Thu 13 Jun 2013 6:09 pm
by saratogaWX
Got to love the Twitter developers .. they turned off the API V1.0 on 11-June-2013 and forced everyone to use the API V1.1 instead.

Sigh.. I've done an update to TweetWX-globals.php that should fix your issues (no customization needed). The changes are to use HTTPS/SSL instead of HTTP for posting the status (and a new destination URL).

Let me know how it works for you :)

Best regards,
Ken

Re: TweetWX script updated for Twitter API V1.1

Posted: Thu 13 Jun 2013 9:27 pm
by saratogaWX
For those who would prefer to update their code in-place, the following changes were made to TweetWX-global.php (also applies to Mike's TweetWX642-global.php script):

Change:

Code: Select all

function do_post($url, $postbody, $port=80, $headers=NULL)
{
  $retarr = array();  // Return value

  $curl_opts = array(CURLOPT_URL => $url,
                     CURLOPT_PORT => $port,
                     CURLOPT_POST => true,
                     CURLOPT_SSL_VERIFYHOST => false,
                     CURLOPT_SSL_VERIFYPEER => false,
                     CURLOPT_POSTFIELDS => $postbody,
                     CURLOPT_RETURNTRANSFER => true);
To:

Code: Select all

function do_post($url, $postbody, $port=443, $headers=NULL)
{
  $retarr = array();  // Return value

  $curl_opts = array(CURLOPT_URL => $url,
                     CURLOPT_PORT => $port,
                     CURLOPT_POST => true,
                     CURLOPT_SSL_VERIFYHOST => true,
                     CURLOPT_SSL_VERIFYPEER => true,
                     CURLOPT_POSTFIELDS => $postbody,
                     CURLOPT_RETURNTRANSFER => true);
Change:

Code: Select all

  $url = 'http://api.twitter.com/1/statuses/update.json';
To:

Code: Select all

  $url = 'https://api.twitter.com/1.1/statuses/update.json';
Change:

Code: Select all

  if ($usePost) {
    $request_url = $url;
    logit("tweet:INFO:request_url:$request_url");
    logit("tweet:INFO:post_body:$query_parameter_string");
    $headers[] = 'Content-Type: application/x-www-form-urlencoded';
    $response = do_post($request_url, $query_parameter_string, 80, $headers);
  } else {
To:

Code: Select all

  if ($usePost) {
    $request_url = $url;
    logit("tweet:INFO:request_url:$request_url");
    logit("tweet:INFO:post_body:$query_parameter_string");
    $headers[] = 'Content-Type: application/x-www-form-urlencoded';
    $response = do_post($request_url, $query_parameter_string, 443, $headers);
  } else {
And your feed should work again.

Best regards,
Ken

Re: TweetWX script updated for Twitter API V1.1

Posted: Sun 14 Jul 2013 6:09 pm
by josecmorales
This php works for the templates with cumulus data?

Re: TweetWX script updated for Twitter API V1.1

Posted: Sun 14 Jul 2013 8:59 pm
by saratogaWX
At present, the TweetWX PHP scripts (for conditions and forecast) work only with Weather-Display for conditions and with the USA NOAA forecasts for the forecast tweets. I'm working on generalizing the scripts to work with any software supported by the template set and forecasts from Environment Canada and WeatherUnderground, but the scripts are not yet finished.

Best regards,
Ken

Re: TweetWX script updated for Twitter API V1.1

Posted: Sun 14 Jul 2013 10:03 pm
by josecmorales
thank you very much Ken, I look forward for that script

Re: TweetWX script updated for Twitter API V1.1

Posted: Wed 14 Jun 2023 3:28 am
by saratogaWX
TweetWX scripts no longer function after 12:00 13-Jun-2023 Pacific. Twitter has suspended the application ID for TweetWX for 'rules violations' (likely over 1500 tweets per month with all the instances sharing the same app ID).
Sigh.. I've now deprecated the scripts and suggest you take them off your cron executions.

Re: TweetWX script updated for Twitter API V1.1

Posted: Sat 17 Jun 2023 4:39 pm
by ConligWX
I'm also surprised that the Twitter module in my Meteobridge Nano is still working!!