forked from jliman/SEOStat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_twitter.php
44 lines (36 loc) · 1.47 KB
/
fetch_twitter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
require_once('inc/db.php');
require_once('inc/helper.php');
require_once('inc/fetch.php');
$fetchTwitter = true;
$saveToDB = true;
echo 'Start fetch Twitter: '.date("Y-m-d H:i:s").'<br>';
foreach ($accounts as $account) {
echo 'Get stat for: '.$account['url'].' - '.date("Y-m-d H:i:s").'<br>';
if ($fetchTwitter && $account['twitter_page'] != '') {
$ch = getCURLResource();
curl_setopt($ch, CURLOPT_URL, "http://twitter.com/".$account['twitter_page']);
$buf2 = curl_exec ($ch);
curl_close($ch);
$twitterData = array();
$tempArr = explode('<span id="following_count" class="stats_count numeric">',$buf2);
$tempArr = explode(' </span>',$tempArr[1]);
$twitterData['following'] = str_replace(',','',trim($tempArr[0]));
$tempArr = explode('<span id="follower_count" class="stats_count numeric">',$buf2);
$tempArr = explode(' </span>',$tempArr[1]);
$twitterData['follower'] = str_replace(',','',trim($tempArr[0]));
$tempArr = explode('<span id="lists_count" class="stats_count numeric">',$buf2);
$tempArr = explode('</span>',$tempArr[1]);
$twitterData['listed'] = str_replace(',','',trim($tempArr[0]));
$tempArr = explode('<span id="update_count" class="stat_count">',$buf2);
$tempArr = explode('</span>',$tempArr[1]);
$twitterData['tweets'] = str_replace(',','',trim($tempArr[0]));
print_r($twitterData);
echo '<br>';
if ($saveToDB) {
saveTwitterStat($account,$twitterData);
}
}
}
echo 'End fetch Twitter: '.date("Y-m-d H:i:s").'<br>';
?>