Twitter API scripts / # @ Removing


#1

I used this: https://github.com/abraham/twitteroauth
I made twitter.php (see code beneath)
It Works

My point is, what I also had with the old scripts.

I want that my tweets with # and @ to be excluded on the site. Those tweets should not be in the list.
I cannot fix it. I think I have removed the RT already, but not the tweets with # and @

Can someone help me?

<?
require_once(“twitteroauth/twitteroauth.php”); //Path to twitteroauth library

$twitteruser = “cooltennis”;
$notweets = 5;
$consumerkey = “";
$consumersecret = "
";
$accesstoken = "
";
$accesstokensecret = "
”;

function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) {
$connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
return $connection;
}

$connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);

$data = $connection->get(“https://api.twitter.com/1.1/statuses/user_timeline.json?include_rts=false&screen_name=".$twitteruser."&count=”.$notweets);
foreach ($data as $tweet) {
echo ‘


’;
echo $tweet->text .’
’ . date(“d-m-Y - G:i”,strtotime($tweet->created_at)) . ‘
’;
}

?>


#2

There are no direct options to exclude @mentions and/or tweets with #hashtags via query parameters. You’ll need to examine the results you get back and filter out the results you don’t want to display after you receive them. Each tweet will have an entities node that describes whether there are hashtags or user_mentions in a tweet – I would key off of that rather than trying to match text that appears in the tweet directly.


#3

It works, and it’s solved.

// beginnen met tellen $num=1;

foreach ($data as $tweet) {

// geen tweets tonen die beginnen met @, # of RT en deze ook niet meetellen in het totaal aantal te tonen tweets
if (substr($tweet->text,0,1) != '@' && stristr($tweet->text, '#') == FALSE && substr($tweet->text,0,2) != 'RT' && $num <= $aantaltweets) {
	echo '<div class="tweet">
	                                   <div class="content">';
	echo preg_replace('/((www|http:\/\/)[^ ]+)/', '<a href="\1"target="_blank">\1</a>', $tweet->text) .'</div><div class="bottom">' . date("d-m-Y \- G:i",strtotime($tweet->created_at)) . '<HR STYLE="width: 100%; height: 1px; color: #000000; background-color: #000000; border: solid #000000 0px;"></div></div>';

	// optellen met 1
	$num++;
}

}


#4

#5

#6

#7