Re: Automatic weather tweets
Posted: Friday 31 January 2014 8:09
Your welcome.
You can take a look at some other scripts with Python instead of bash.
You can take a look at some other scripts with Python instead of bash.
This code does the problem I think:Invalid request parameters
Code: Select all
update=$(curl -v -s -b "cookie.txt" -c "cookie.txt" -L --sslv3 -A "$uagent" -d "authenticity_token=$tweettoken&tweet[text]=$tweet&tweet[display_coordinates]=false" "https://mobile.twitter.com/")
Code: Select all
tweet="hallo wereld"
Code: Select all
[+] Fetching twitter.com...
[+] Submitting the login form...
[+] Getting compose tweet page...
[+] Posting a new tweet: hallo wereld...
[+] Logging out...
Code: Select all
#! /usr/bin/env python
import tweepy
from datetime import datetime
API_KEY = ' '
API_SECRET = ' '
ACCESS_TOKEN = ' '
ACCESS_TOKEN_SECRET = ' '
auth = tweepy.OAuthHandler(API_KEY, API_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
tempfile = open("/mnt/usbstorage/tweets/weather-tweet.txt")
thetext = tempfile.read()
tempfile.close()
api.update_status(thetext)
Code: Select all
#!/bin/bash
thermo=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=37"`
echo $thermo > /mnt/usbstorage/tweets/weather-data.txt
temperature=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $17, $18}' | awk '{print $3}' | sed 's/\"//g'`
hygro=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=37"`
echo $hygro > /mnt/usbstorage/tweets/weather-data.txt
hygro=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $18, $19}' | awk '{print $3}' | sed 's/\"//g'`
rain=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=40"`
echo $rain > /mnt/usbstorage/tweets/weather-data.txt
rain=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $13, $14}' | awk '{print $3}' | sed 's/\"//g' | sed 's/,//g'`
wind=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=38"`
echo $wind > /mnt/usbstorage/tweets/weather-data.txt
dir=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $20, $21}' | awk '{print $3}' | sed 's/\"//g' | sed 's/,//g'`
speed=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $22, $23}' | awk '{print $3}' | sed 's/\"//g' | sed 's/,//g'`
chill=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $15, $16}' | awk '{print $3}' | sed 's/\"//g' | sed 's/,//g'`
baro=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=37"`
echo $baro > /mnt/usbstorage/tweets/weather-data.txt
baro=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $14, $15}' | awk '{print $3}' | sed 's/\"//g' | sed 's/,//g'`
zicht=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=41"`
echo $zicht > /mnt/usbstorage/tweets/weather-data.txt
zicht=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $16, $17}' | awk '{print $3}' | sed 's/\"//g' | sed 's/,//g'`
uv=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=39"`
echo $uv > /mnt/usbstorage/tweets/weather-data.txt
uv=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $16, $17}' | awk '{print $3}' | sed 's/\"//g' | sed 's/,//g'`
echo -ne "#Zoutkamp\nTemp: $temperature C\nWindchill: $chill C\nLuchtvochtigheid: $hygro %\nNeerslag: $rain mm\nWind: $dir / $speed km/h\nBaro: $baro hPa\nZicht: $zicht km\nUV: $uv" > /mnt/usbstorage/tweets/weather-tweet.txt
sudo python /home/pi/domoticz/scripts/python/weer.py