Twitting từ linux shell
Đăng bởi dongthao on Tháng Chín 30, 2008
Vì lười dùng các chương trình giao diện cũng như mở trình duyệt, tôi vừa viết một script nhỏ xíu để post twitter từ shell của linux (sử dụng wget). Nội dung của nó như sau:
#!/bin/bash
## Provide your twitter username and password here
username=
password=
##
message=”"
if [ $# -gt 0 ]; then
while [ "$1" != "" ]; do
message=”${message} ${1}”
shift
done
else
echo “Enter your message as the parameter.”
fi
echo “POSTING” $message
wget -q –delete-after –user=$username –password=$password –post-data status=”${message}” http://twitter.com/statuses/update.xml
echo “DONE.”
Save đoạn script trên vào 1 file sau đó iền username và password của bạn (đừng lo, tôi không hề biết tí gì về thông tin này đâu
) đặt tên là twitsh. Dùng lệnh chmod để có thể thực thi file này:
$ chmod +x twitsh
Để post message ” Reading newspaper now” lên twitter.com ta gõ lệnh:
$ ./twitsh Reading newspaper now
Nếu lười … hơn tôi, bạn cũng có thể tải script tôi viết sẵn tại đây :p, điền username, password vào, chmod và sử dụng ngay.
Chúc vui.


nano đã nói
want more fun? try http://www.sakana.fr/blog/2007/03/18/scripting-twitter-with-curl/
dongthao đã nói
Thanks nano, link rất hữu ích.
phuong đã nói
#!/bin/bash
## Provide your twitter username and password here
username=
password=
##
message=””
if [ $# -gt 0 ]; then
while [ "$1" != "" ]; do
message=”${message} ${1}”
shift
done
else
echo “Enter your message as the parameter.”
fi
echo “POSTING” $message
wget -q –delete-after –user=$username –password=$password –post-data status=”${message}” http://twitter.com/statuses/update.xml
echo “DONE.”