date_default_timezone_set("UTC");
//Facebook
ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
$rss_url = "https://www.facebook.com/feeds/page.php?format=atom10&id=135405833136323";;
$xml = simplexml_load_file( $rss_url );
$out = '';
$i = 0;
foreach( $xml->entry as $item ){
$fblink=$item->link['href'];
$tmp=preg_replace('`]*>.+?`is','',$item->content);$tmp1=str_replace('#villerssurmer','',$tmp);
$tmp2=str_replace('
','',$tmp1);$tmp2=str_replace('
','',$tmp2);$tmp2=str_replace('
','',$tmp2);
$tab_post[$i]=array('public'=> strtotime($item->published),'type'=> 'facebook', 'texte' => $tmp2, 'lien' => $fblink);
if( $i == 10 ) break;
$i++;
}
//Twitter
$consumer_key = 'yycyM2vfaKZvDSbHEnWhw9rtg';
$consumer_secret = 'DbBNQe0yZsRjcCKqFAU96xLhHjDMXsa7UVUVmMqhsTN9ykvtMV';
$oauth_access_token = '3309221338-txJRSeHCwL03ozICtsGTOEZOP0P8gQ7JyNfND1l';
$oauth_access_token_secret = 'tVgb3sUW0p9YdN625v4BZrCmsTKLSGdeWx01p7Nds7npK';
error_reporting(E_ALL ^ E_NOTICE);
$screen_name ="OTVillersurmer";
$count = 10;
function buildBaseString($baseURI, $method, $params) {
$r = array();
ksort($params);
foreach($params as $key=>$value){
$r[] = "$key=" . rawurlencode($value);
}
return $method."&" . rawurlencode($baseURI) . '&' . rawurlencode(implode('&', $r));
}
function buildAuthorizationHeader($oauth) {
$r = 'Authorization: OAuth ';
$values = array();
foreach($oauth as $key=>$value)
$values[] = "$key=\"" . rawurlencode($value) . "\"";
$r .= implode(', ', $values);
return $r;
}
$url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
$oauth = array( 'screen_name' => $screen_name,
'count' => $count,
'oauth_consumer_key' => $consumer_key,
'oauth_nonce' => time(),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_token' => $oauth_access_token,
'oauth_timestamp' => time(),
'oauth_version' => '1.0');
$base_info = buildBaseString($url, 'GET', $oauth);
$composite_key = rawurlencode($consumer_secret) . '&' . rawurlencode($oauth_access_token_secret);
$oauth_signature = base64_encode(hash_hmac('sha1', $base_info, $composite_key, true));
$oauth['oauth_signature'] = $oauth_signature;
$header = array(buildAuthorizationHeader($oauth), 'Expect:');
$options = array( CURLOPT_HTTPHEADER => $header,
//CURLOPT_POSTFIELDS => $postfields,
CURLOPT_HEADER => false,
CURLOPT_URL => $url . '?screen_name='.rawurlencode($screen_name).'&count='.$count,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false);
$feed = curl_init();
curl_setopt_array($feed, $options);
$json = curl_exec($feed);
curl_close($feed);
$twitter_data = json_decode($json);
$count = 0;
if(is_array($twitter_data)) {
foreach($twitter_data as $row) {
if($count > 0) {
$json_format .= '
';
}
$media = $row->entities->media;
$attached = "";
if(!empty($media)) {
foreach($media as $key) {
$attached .= ' ';
}
}
$tp_text=str_replace('"',' ',$row->text);
if(strpos($tp_text,'http://')){$tp_lien=substr($tp_text,strpos($tp_text,'http://'));$tp_text=substr($tp_text,0,strpos($tp_text,'http://')-1);
;}else $tp_lien='';
//$json_format .= '$TW_title['.$count.']="'.$tp_text.'";$TW_id['.$count.']="'.$row->id_str.'";$TW_author['.$count.']="'.$row->user->screen_name.'";$TW_published['.$count.']='.strtotime($row->created_at).';$TW_media['.$count.']="'.$key->media_url.'";$TW_link['.$count.']="'.$tp_lien.'";';
$tab_post[$count+10]=array('public'=> strtotime($row->created_at),'type'=> 'twitter', 'texte' => $tp_text, 'lien' => $row->id_str);
$count++;
}
}
//print_r($tab_post);
function fonctionComparaison($a, $b){
return $a['public'] > $b['public'];
}
usort($tab_post, 'fonctionComparaison');
$time=time();
$social='