[英]Post to twitter via curl
我必須允許客戶在我正在構建的博客上發布文章,並在twitter,facebook和linkedin上自動發布帖子。 我無法為客戶創建應用程序facebook / twitter,甚至無法給我密碼。 所以我想用curl(或其他方法)從php創建一個帖子。 我找到了這個: http : //www.flameweb.net/using_php_to_update_twitter我輸入了我的用戶名和密碼,運行代碼並返回“成功”,但Twitter上沒有帖子。 為什么?
這是360percents.com 腳本的修改版本。 它使用移動Twitter。 當我使用它時,它工作,我現在沒有檢查。
Signin.sh:
#!/bin/bash
#REQUIRED PARAMS
username=$1
password=$2
cookie="$username.cookie"
#EXTRA OPTIONS
uagent="Mozilla/5.0"
#proxy="--socks5 127.0.0.1:9050"
#INITIAL PAGE
initpage=`curl $proxy -s -b $cookie -c $cookie -L --sslv3 -A "$uagent" "https://mobile.twitter.com/session/new"`
token=`echo "$initpage" | grep "authenticity_token" | sed -e 's/.*value="//' | sed -e 's/" \/>.*//' | tail -n 1`
#LOGIN
loginpage=`curl $proxy -s -b $cookie -c $cookie -L --sslv3 -A "$uagent" -d "authenticity_token=$token&username=$username&password=$password" "https://mobile.twitter.com/session"`
Tweet.sh:
#!/bin/bash
#REQUIRED PARAMS
username=$1
password="$2"
tweet=$3
cookie="$username.cookie"
#EXTRA OPTIONS
uagent="Mozilla/5.0"
#proxy="--socks5 127.0.0.1:9050"
#HOME PAGE
homepage=`curl $proxy -s -b $cookie -c $cookie -L -A "$uagent" "http://mobile.twitter.com/"`
if [ "$homepage" != "${homepage/Sign in/}" ]; then
echo "Signing $username in"
./signin.sh $username $password
fi
echo "Tweeting $tweet by $username"
#TWEET
tweettoken=`echo "$homepage" | grep "authenticity_token" | sed -e 's/.*value="//' | sed -e 's/" \/>.*//' | tail -n 1`
update=`curl $proxy -s -b $cookie -c $cookie -L -A "$uagent" -d "authenticity_token=$tweettoken&tweet[text]=$tweet&tweet[display_coordinates]=false" "http://mobile.twitter.com/"`
您是否嘗試過使用Twitter API?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.