79 lines
1.7 KiB
PHP
79 lines
1.7 KiB
PHP
<?php
|
|
include('../config/config.php');
|
|
include('../includes/classes/class.Tweet.php');
|
|
include('includes/functions.php');
|
|
include('includes/twitteroauth.php');
|
|
|
|
$objTweet=new Tweet();
|
|
$allTweetIds=$objTweet->getAllTweetIds();
|
|
|
|
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($consumer_key, $consumer_secret, $user_token, $user_secret);
|
|
|
|
$temp=array();
|
|
|
|
if($allTweetIds)
|
|
{
|
|
$index=0;
|
|
$count=0;
|
|
$tweetIdsArray=array();
|
|
|
|
foreach($allTweetIds as $id)
|
|
{
|
|
if($count<100)
|
|
{
|
|
$tweetIdsArray[$index][$count]=$id->tweet_id;
|
|
}
|
|
|
|
if($count==99)
|
|
{
|
|
$index++;
|
|
$count=0;
|
|
continue;
|
|
}
|
|
$count++;
|
|
}
|
|
|
|
foreach($tweetIdsArray as $idArray)
|
|
{
|
|
$ids="";
|
|
for($i=0;$i<sizeof($idArray);$i++)
|
|
{
|
|
if($i<sizeof($idArray)-1)
|
|
{
|
|
$ids.=$idArray[$i].",";
|
|
}
|
|
else
|
|
{
|
|
$ids.=$idArray[$i];
|
|
}
|
|
}
|
|
|
|
$requestUrl="https://api.twitter.com/1.1/statuses/lookup.json?id=".$ids."&trim_user=true&map=true";
|
|
$tweets=$connection->get($requestUrl);
|
|
$response=json_decode(json_encode($tweets->id),true);
|
|
|
|
for($i=0;$i<sizeof($idArray);$i++)
|
|
{
|
|
if($response[$idArray[$i]]=='' || $response[$idArray[$i]]==NULL)
|
|
{
|
|
$tweetId=$idArray[$i];
|
|
$check_tweet = $connection->get("https://api.twitter.com/1.1/statuses/show/'$tweetId'.json");
|
|
$check_response=$check_tweet->errors;
|
|
$check_code=$check_response[0]->code;
|
|
|
|
if($check_code==34)
|
|
{
|
|
$objTweet->status='Y';
|
|
$objTweet->id=$tweetId;
|
|
$objTweet->updateTweetStatus();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
?>
|