Vielleicht hilft das ja
Code:
#!/bin/bash
#Twitter status update bot by http://360percents.com
#Author: Luka Pusic <pusic93@gmail.com>
#REQUIRED PARAMS
username="blasmireinen"
password="blasmireinen"
tweet="$*" #must be less than 140 chars
#EXTRA OPTIONS
uagent="Mozilla/5.0" #user agent (fake a browser)
sleeptime=0 #add pause between requests
if [ $(echo "${tweet}" | wc -c) -gt 140 ]; then
echo "[FAIL] Tweet must not be longer than 140 chars!" && exit 1
fi
touch "cookie.txt" #create a temp. cookie file
#INITIAL PAGE
echo "[+] Fetching twitter.com..." && sleep $sleeptime
initpage=`curl -s -b "cookie.txt" -c "cookie.txt" -L --sslv3 -A "$uagent" "https://mobile.twitter.com/session/new"`
token=`echo "$initpage" | grep "authenticity_token" | sed -e 's/.*value="//' | sed -e 's/" \/>.*//'`
#LOGIN
echo "[+] Submitting the login form..." && sleep $sleeptime
loginpage=`curl -s -b "cookie.txt" -c "cookie.txt" -L --sslv3 -A "$uagent" -d "authenticity_token=$token&username=$username&password=$password" "https://mobile.twitter.com/session"`
#HOME PAGE
echo "[+] Getting your twitter home page..." && sleep $sleeptime
homepage=`curl -s -b "cookie.txt" -c "cookie.txt" -L -A "$uagent" "http://mobile.twitter.com/"`
#TWEET
echo "[+] Posting a new tweet..." && sleep $sleeptime
tweettoken=`echo "$homepage" | grep "authenticity_token" | sed -e 's/.*value="//' | sed -e 's/" \/>.*//' | tail -n 1`
update=`curl -s -b "cookie.txt" -c "cookie.txt" -L -A "$uagent" -d "authenticity_token=$tweettoken&tweet[text]=$tweet&tweet[display_coordinates]=false" "http://mobile.twitter.com/"`
#LOGOUT
echo "[+] Logging out..."
logout=`curl -s -b "cookie.txt" -c "cookie.txt" -L -A "$uagent" "http://mobile.twitter.com/session/destroy"`
rm "cookie.txt"
oder das da
Code:
<?php function twitterSetStatus($user,$pwd,$status) {
if (!function_exists("curl_init")) die("twitterSetStatus needs CURL module, please install CURL on your php.");
$ch = curl_init();
// -------------------------------------------------------
// get login form and parse it
curl_setopt($ch, CURLOPT_URL, "https://mobile.twitter.com/session/new");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3 ");
$page = curl_exec($ch);
$page = stristr($page, "<div class='signup-body'>");
preg_match("/form action=\"(.*?)\"/", $page, $action);
preg_match("/input name=\"authenticity_token\" type=\"hidden\" value=\"(.*?)\"/", $page, $authenticity_token);
// -------------------------------------------------------
// make login and get home page
$strpost = "authenticity_token=".urlencode($authenticity_token[1])."&username=".urlencode($user)."&password=".urlencode($pwd);
curl_setopt($ch, CURLOPT_URL, $action[1]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $strpost);
$page = curl_exec($ch);
// check if login was ok
preg_match("/\<div class=\"warning\"\>(.*?)\<\/div\>/", $page, $warning);
if (isset($warning[1])) return $warning[1];
$page = stristr($page,"<div class='tweetbox'>");
preg_match("/form action=\"(.*?)\"/", $page, $action);
preg_match("/input name=\"authenticity_token\" type=\"hidden\" value=\"(.*?)\"/", $page, $authenticity_token);
// -------------------------------------------------------
// send status update
$strpost = "authenticity_token=".urlencode($authenticity_token[1]);
$tweet['display_coordinates']='';
$tweet['in_reply_to_status_id']='';
$tweet['lat']='';
$tweet['long']='';
$tweet['place_id']='';
$tweet['text']=$status;
$ar = array("authenticity_token" => $authenticity_token[1], "tweet"=>$tweet);
$data = http_build_query($ar);
curl_setopt($ch, CURLOPT_URL, $action[1]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$page = curl_exec($ch);
return true;
}
if ($_POST['tweet'])
$user = "nutzer";
$pwd = "blaaaa";
$status = $_POST['tweet'];
twitterSetStatus($user,$pwd,$status);
?>
das 2te ist php. Sind beides sachen die ich im inet klaute
Die sind beide für twitter, um einen Tweet zu schreiben