• Wieder einmal haben uns unsere Apfeltalker tolle Fotos zur Abstimmung eingesandt. Welches ist Euer Favorit? Stimmt mit ab! Hier geht es zur Abstimmung --> Klick
  • Es ist bereits Apfeltalk-Tradition und wir möchten sie auch in diesem Jahr fortsetzen: Unser Apfeltalk-Weihnachtslogo-Wettbewerb hat begonnen! Gestaltet für uns das Weihnachtsbanner, das im Monat Dezember bis zum Weihnachtsfest unsere Webseite schmücken soll. Lasst Eurer Kreativität freien Lauf! Hier geht es zum Wettbewerb --> Klick

PHP - Twitter, StudiVZ, SchülerVZ Brücke

MACRASSI

Gelbe Schleswiger Reinette
Registriert
21.11.04
Beiträge
1.754
Hi Ihr!
Ich hab ein nettes kleines PHP File geschrieben, das den letzten Twitter Eintrag in den Buschfunk bei Schüler und Studi VZ schreibt.

Code:
<?
//Edit this with your information...

//StudiVZ
$loginStudi = "xxx";
$pwStudi = "xxx";

//SchuelerVZ
$loginSch = "xxx";
$pwSch = "xxx";

//Twitter Account Name
$loginTwitter = "xxx";




//DO NOT EDIT ANYTHING DOWN HERE!
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/$loginTwitter.json");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$buffer = curl_exec($ch);
$json = json_decode($buffer);
$text = $json[0]->text;


if (substr($text,0,strlen('@')) != '@'){
if(!file_exists("timestamp.txt")){
$fp = fopen("timestamp.txt", "w"); 
fclose($fp);
}
$handle = fopen("timestamp.txt","r");
$n = fgets($handle,1000);
fclose($handle);
if(md5($text) != $n){

$url = "http://m.studivz.net/op/studivz/de/mcat/login/";
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en)");
$buffer = curl_exec($ch);
$needle = "/op/studivz/de/mcat/login/;jsessionid=";
$session = substr($buffer,strpos($buffer,$needle)+strlen($needle),32); // REGEX = nerdy 


$url = "http://m.studivz.net/op/studivz/de/mcat/login/;jsessionid=".$session;
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=$loginStudi&password=$pwStudi");
$buffer = curl_exec($ch);


$url = "http://m.studivz.net/op/studivz/de/mcat/status/senden/;jsessionid=".$session;
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, "text=$text");
$buffer = curl_exec($ch);


$url = "http://m.schuelervz.net/op/schuelervz/de/mcat/login/";
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en)");
$buffer = curl_exec($ch);
$needle = "/op/schuelervz/de/mcat/login/;jsessionid=";
$session = substr($buffer,strpos($buffer,$needle)+strlen($needle),32); // REGEX = nerdy 


$url = "http://m.schuelervz.net/op/schuelervz/de/mcat/login/;jsessionid=".$session;
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=$loginSch&password=$pwSch");
$buffer = curl_exec($ch);


$url = "http://m.schuelervz.net/op/schuelervz/de/mcat/status/senden/;jsessionid=".$session;
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, "text=$text");
$buffer = curl_exec($ch);




$fp=fopen("timestamp.txt","w");
fputs($fp, md5($text));
fclose($fp);


}
}
?>

Orginalpost: @Twitter


Viel Spaß Damit.
 
  • Like
Reaktionen: Bananenbieger
geiles teil!! :D und das funktioniert auch noch :)
 
respekt! gute arbeit. werde es zwar nicht verwenden, aber da gibts bestimmt leute, die so was brauchen könnten.
 
danke für das tolle php file, werde es gleich mal ausprobieren

Edit: Funktioniert !!
 
Ich brauchs nicht, aber trotzdem Respekt, dass du sowas hervorgebracht hast! Ist sicher praktisch für manche Leute ;)
 
Hab nochmal nen kleines Update. Diesmal sollte das Problem mit den ' Zeichen bei StudiVZ und SchülerVZ behoben sein.

Gruß Rasmus

Code:
<?
//Edit this with your information...

//StudiVZ
$loginStudi = "xxx";
$pwStudi = "xxx";

//SchuelerVZ
$loginSch = "xxx";
$pwSch = "xxx";

//Twitter Account Name
$loginTwitter = "xxx";




//DO NOT EDIT ANYTHING DOWN HERE!
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/$loginTwitter.json");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$buffer = curl_exec($ch);
$json = json_decode($buffer);
$text = $json[0]->text;

$text = str_replace("'","’",$text);
$text = str_replace('"',"”",$text);

if (substr($text,0,strlen('@')) != '@'){
if(!file_exists("timestamp.txt")){
$fp = fopen("timestamp.txt", "w"); 
fclose($fp);
}
$handle = fopen("timestamp.txt","r");
$n = fgets($handle,1000);
fclose($handle);
if(md5($text) != $n){

$url = "http://m.studivz.net/op/studivz/de/mcat/login/";
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en)");
$buffer = curl_exec($ch);
$needle = "/op/studivz/de/mcat/login/;jsessionid=";
$session = substr($buffer,strpos($buffer,$needle)+strlen($needle),32); // REGEX = nerdy 


$url = "http://m.studivz.net/op/studivz/de/mcat/login/;jsessionid=".$session;
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=$loginStudi&password=$pwStudi");
$buffer = curl_exec($ch);


$url = "http://m.studivz.net/op/studivz/de/mcat/status/senden/;jsessionid=".$session;
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, "text=$text");
$buffer = curl_exec($ch);


$url = "http://m.schuelervz.net/op/schuelervz/de/mcat/login/";
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en)");
$buffer = curl_exec($ch);
$needle = "/op/schuelervz/de/mcat/login/;jsessionid=";
$session = substr($buffer,strpos($buffer,$needle)+strlen($needle),32); // REGEX = nerdy 


$url = "http://m.schuelervz.net/op/schuelervz/de/mcat/login/;jsessionid=".$session;
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=$loginSch&password=$pwSch");
$buffer = curl_exec($ch);


$url = "http://m.schuelervz.net/op/schuelervz/de/mcat/status/senden/;jsessionid=".$session;
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, "text=$text");
$buffer = curl_exec($ch);




$fp=fopen("timestamp.txt","w");
fputs($fp, md5($text));
fclose($fp);


}
}
?>
 
  • Like
Reaktionen: C.Schwab