Author Topic: TweetWX Script Issues  (Read 425 times)

0 Members and 1 Guest are viewing this topic.

Offline Gonzo1982

  • Member
  • *
  • Posts: 8
TweetWX Script Issues
« on: April 19, 2018, 11:31:39 AM »
So instead of using cron to run the script (Bluehost made it to complicated and I don't want to upgrade to a VPS), I'm using a wscript on my windows computer to execute a powershell script (so that its silent, no powershell window) and using task scheduler to execute the script during the schedule I specified.

Here is that script for those interested:

Save As tweetforecast.ps1

Code: [Select]
Invoke-WebRequest http://websiteaddress/TweetWX/TweetWX-forecast.php
Save As forecast.js:

Code: [Select]
var wshShell = new ActiveXObject("WScript.Shell");
wshShell.Run('%SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -ExecutionPolicy Bypass -File "C:\\Scripts\\tweetforecast.ps1"', 0, false);

Now create a task in task scheduler that executes wscript and put the location of the forecast.js file in the argument section.

Anyways back to my issue:

I got this error this morning and I suspect it is because the forecast hasn't been updated, but I'd like it to go ahead and post anyways, any way to do that?

Code: [Select]
    [title] => Current watches, warnings, and advisories for Coffee (TNZ077) TN
)
 -->
<!-- preparing 1 warning links -->
<!-- now 10:19 am CDT Apr 19, 2018 (3:19 pm GMT Apr 19, 2018) -->
<!-- alert expires 12:00 pm CDT Apr 19, 2018 (2018-04-19T12:00:00-05:00) -->
<!-- URL cache saved to /home2/coffehf2/cache/forecast-URLcache.txt with 1 entries. -->
advforecast2.php (JSON) - V5.07 - 14-Apr-2018
NWS Fcst:  Today: Mostly Sunny , Hi 56F; Tonight: Mostly Clear then Patchy Frost , Lo 35F; Friday: Patchy Frost then Sunny , Hi 68F;  https://bit.ly/2JTyYqa #TNwx
len=162 bytes.
UTF='NWS Fcst:  Today: Mostly Sunny , Hi 56F; Tonight: Mostly Clear then Patchy Frost , Lo 35F; Friday: Patchy Frost then Sunny , Hi 68F;  https://bit.ly/2JTyYqa #TNwx' len=162 bytes.
status={
  "errors": [
    {
      "code": 187,
      "message": "Status is a duplicate."
    }
  ]
}

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: TweetWX Script Issues
« Reply #1 on: April 20, 2018, 10:11:30 AM »
It's not a script problem.  twitter issues the 'Status is a duplicate' if the text of the tweet exactly matches the prior tweet.  Forecasts change 4 times a day for the NWS, so if you run the script hourly, youll get only 4 successful tweets per day (normal) and rejects when the forecast text has not changed from the last successful tweet.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Gonzo1982

  • Member
  • *
  • Posts: 8
Re: TweetWX Script Issues
« Reply #2 on: April 20, 2018, 10:15:12 AM »
I am only posting 4 times a day, our local office post at 4am, 10am, 4pm, and 10pm.  The 10am post was the one that the issue came from.  I guess they were late updating.  I’ll move it out later.

 

anything