Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende Überarbeitung | |||
| archiv:coding:php:stwitterapi [2023/11/05 21:48] – psycore | archiv:coding:php:stwitterapi [2023/11/08 12:09] (aktuell) – gelöscht psycore | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | {{template> | ||
| - | ====== Secure twitter API ====== | ||
| - | |||
| - | Secure twitter API kann Statusmeldungen von [[http:// | ||
| - | |||
| - | ===== twitter.php ===== | ||
| - | |||
| - | <code php twitter.php> | ||
| - | <?php | ||
| - | /* ---------------------------------------- */ | ||
| - | // Change these parameters with your Twitter | ||
| - | // user name and Twitter password. | ||
| - | /* ---------------------------------------- */ | ||
| - | $twitter_username = ' | ||
| - | $twitter_psw = ' | ||
| - | //noch nicht integriert | ||
| - | $myself = ' | ||
| - | /* ---------------------------------------- */ | ||
| - | |||
| - | /* Don't change the code belove | ||
| - | /* ---------------------------------------- */ | ||
| - | require(' | ||
| - | if(isset($_POST[' | ||
| - | $twitter_message=$_POST[' | ||
| - | if(strlen($twitter_message)< | ||
| - | $error=1; | ||
| - | } else { | ||
| - | $twitter_status=postToTwitter($twitter_username, | ||
| - | } | ||
| - | } | ||
| - | /* ---------------------------------------- */ | ||
| - | ?> | ||
| - | < | ||
| - | <html xmlns=" | ||
| - | < | ||
| - | <meta http-equiv=" | ||
| - | < | ||
| - | <style type=" | ||
| - | body{font-family:' | ||
| - | h2{color:# | ||
| - | h3{color:# | ||
| - | p{font-size: | ||
| - | input{font-size: | ||
| - | a:link, a:visited, a: | ||
| - | a: | ||
| - | div.footer{padding: | ||
| - | div.msg{background:# | ||
| - | div.code{padding: | ||
| - | </ | ||
| - | </ | ||
| - | |||
| - | < | ||
| - | < | ||
| - | < | ||
| - | <!-- This is the form that you can reuse in your site --> | ||
| - | <?php if(isset($_POST[' | ||
| - | <div class=" | ||
| - | <?php } else if(isset($error)){?> | ||
| - | <div class=" | ||
| - | <?php }?> | ||
| - | < | ||
| - | <form action=" | ||
| - | <input name=" | ||
| - | <input type=" | ||
| - | </ | ||
| - | <!-- END --> | ||
| - | |||
| - | <div class=" | ||
| - | For info please visit <a href=" | ||
| - | <br /> | ||
| - | </ | ||
| - | |||
| - | </ | ||
| - | </ | ||
| - | </ | ||
| - | |||
| - | ===== twitterAPI.php ===== | ||
| - | |||
| - | <code php> | ||
| - | <?php | ||
| - | |||
| - | // A simple function using Curl to post (GET) to Twitter | ||
| - | // Kosso : March 14 2007 | ||
| - | |||
| - | function postToTwitter($username, | ||
| - | |||
| - | $host = " | ||
| - | |||
| - | $ch = curl_init(); | ||
| - | curl_setopt($ch, | ||
| - | curl_setopt($ch, | ||
| - | curl_setopt($ch, | ||
| - | curl_setopt($ch, | ||
| - | curl_setopt($ch, | ||
| - | curl_setopt($ch, | ||
| - | curl_setopt($ch, | ||
| - | |||
| - | $result = curl_exec($ch); | ||
| - | // Look at the returned header | ||
| - | $resultArray = curl_getinfo($ch); | ||
| - | |||
| - | curl_close($ch); | ||
| - | |||
| - | if($resultArray[' | ||
| - | | ||
| - | } else { | ||
| - | | ||
| - | } | ||
| - | return $twitter_status; | ||
| - | } | ||
| - | ?> | ||
| - | </ | ||