この記事は古いです
ここを開いて一番上に出てきた記事に最新版が貼ってあります、たぶんーーーーーーーーーー
とりあえず投稿のみ
AKEYとASECRETは通常版のshtterで取得してから書き込んでください
こんな感じで投稿できる
# ./shtter.sh "`cat /proc/loadavg`"
openssl-utilsとcurlが必要です
# opkg update
# opkg install openssl-util curl
shtter.sh (last update 2010/05/22)
This script lisence is GPL.
#!/bin/sh
CKEY="U3DhP7CpPx0bNCzdAFShg"
CSECRET="eAQ13OTo7BhroXQc5dA5oOqEuXhAf7yABVKpkbR7so"
AKEY=""
ASECRET=""
UpdateTimeLine()
{
URL="http://api.twitter.com/1/statuses/update.xml"
TWEET="`Encode \"$@ http://bit.ly/dsKezn #shtter\"`"
if [ "$TWEET" == "" ]
then
echo error
exit 1
fi
NONCE="`date +%s | md5sum | cut -c1-32`"
TIMESTAMP="`date +%s`"
PARAM="oauth_consumer_key=$CKEY&oauth_nonce=$NONCE&oauth_signature_method=HMAC-SHA1&oauth_timestamp=$TIMESTAMP&oauth_token=$AKEY&oauth_version=1.0&status=$TWEET"
EURL="`UrlEncode $URL`"
EPARAM="`echo $PARAM | sed 's/%/%25/g'`"
EPARAM="`UrlEncode $EPARAM`"
QUERY="POST&$EURL&$EPARAM"
HASH="`echo -n $QUERY | openssl sha1 -hmac "$CSECRET&$ASECRET" -binary | openssl base64`"
HASH=`UrlEncode $HASH`
POST="$PARAM&oauth_signature=$HASH"
RESULT="`curl -s --data \"$POST\" \"$URL\"`"
}
UrlEncode()
{
echo "$@" | sed 's/&/%26/g; s/+/%2B/g; s/\//%2F/g; s/:/%3A/g; s/=/%3D/g'
}
Encode()
{
LEN="`echo -n \"$@\" | wc -L`"
if [ $LEN -gt 140 ]
then
return
fi
echo "$@" | sed 's/./\0\n/g' | grep '[^-._~0-9a-zA-Z]' | sort | uniq >/tmp/enc.txt
cat /tmp/enc.txt | while read l
do
if [ "$l" == "" ]; then l=" "; fi
HEX="`echo -n \"$l\" | hexdump -e '16/1 "%02X" "\n"' | sed 's/ *$//; s/\(..\)/%\1/g'`"
if [ "$l" == "/" ]; then l="\/"; fi
echo "s/$l/$HEX/g"
done >/tmp/rep.sed
echo "$@" | sed -f /tmp/rep.sed
rm /tmp/enc.txt /tmp/rep.sed
}
UpdateTimeLine "$@"
0 件のコメント:
コメントを投稿