Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('twitter-api-php/TwitterAPIExchange.php'); // https://github.com/J7mbo/twitter-api-php
- $settings = array(
- 'consumer_key' => 'API_KEY',
- 'consumer_secret' => 'API_SECRET_KEY',
- 'oauth_access_token' => '',
- 'oauth_access_token_secret' => ''
- );
- $screen_name = 'EurenikZ'; // Twitter Account Name
- $url = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
- $getfield = '?screen_name='.$screen_name;
- $requestMethod = 'GET';
- $twitter = new TwitterAPIExchange($settings);
- $user_timeline = $twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest();
- $i = -1;
- $safety = 0;
- do {
- $i++;
- $safety++;
- $try = json_decode($user_timeline)[$i]->in_reply_to_status_id;
- } while (($try != NULL) && $safety < 20);
- $latestTweet = substr(json_decode($user_timeline)[$i]->text, 0, strpos(json_decode($user_timeline)[$i]->text, 'https://t.co/'));
- $created_at = json_decode($user_timeline)[$i]->created_at;
- $id = json_decode($user_timeline)[$i]->id;
- $url = 'https://twitter.com/'.$screen_name.'/status/'.$id;
- // Datum auswerten
- $monat = substr($created_at, 4, 3);
- if($monat == 'Jan') $monat = '01';
- if($monat == 'Feb') $monat = '02';
- if($monat == 'Mar') $monat = '03';
- if($monat == 'Apr') $monat = '04';
- if($monat == 'May') $monat = '05';
- if($monat == 'Jun') $monat = '06';
- if($monat == 'Jul') $monat = '07';
- if($monat == 'Aug') $monat = '08';
- if($monat == 'Sep') $monat = '09';
- if($monat == 'Okt') $monat = '10';
- if($monat == 'Nov') $monat = '11';
- if($monat == 'Dec') $monat = '12';
- $tag = substr($created_at , 8, 2);
- $stunde = substr($created_at , 11, 2);
- $minute = substr($created_at , 14, 2);
- $jahr = substr($created_at , 26, 4);
- $created_at = date_create($tag.'.'.$monat.'.'.$jahr.' '.$stunde.':'.$minute);
- date_add($created_at, date_interval_create_from_date_string('2 hours'));
- $datum = date_format($created_at, 'd.m. H:i');
- echo $latestTweet.'<br><br>Vom '.$datum.' Uhr.<br><br>'.$url;
- ?>
Add Comment
Please, Sign In to add comment