- Unknown
- 11:24 م
- computer ، net
- لاتوجد تعليقات
Fetch RSS Feed from Facebook and Twitter
<!–?php–>
/*Paste the below function into your theme function file */
function getFacebookid_json($facebook_url){
$last_url_node = @explode(“/”,$facebook_url);
$last_url_node = $last_url_node[count($last_url_node)-1];
$url = “https://graph.facebook.com/”.$last_url_node;
$ch = curl_init($url);
facebook-twitter-feed
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Host: graph.facebook.com’));
$data = curl_exec($ch);
$data = json_decode($data,true);
curl_close($ch);
return $data['id'];
}
function gettwitterid_json($twitter_url){
$last_url_node = @explode(“=”,$twitter_url);
$last_url_node = $last_url_node[count($last_url_node)-1];
$url = “https://api.twitter.com/1/users/show.json?screen_name=”.$last_url_node;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Host: api.twitter.com’));
$data = curl_exec($ch);
$data = json_decode($data,true);
curl_close($ch);
return $data['id'];
}
/*Paste the below code wherever you want to display your social feeds*/
$fbid = “facebook_uname”;
$twitid = “twitter_sname”;
$fb_rss_url = ‘https://graph.facebook.com/’.$fbid;
$twit_rss_url = ‘https://api.twitter.com/1/users/show.json?screen_name=’.$twitid;
$facebookident = getFacebookid_json($fb_rss_url);
$twitid = gettwitterid_json($twit_rss_url);
$fbrss = ‘http://www.facebook.com/feeds/page.php?format=rss20&id=’.$facebookident;
$twrss = ‘http://api.twitter.com/1/statuses/user_timeline.rss?user_id=’.$twitid;
include_once(ABSPATH.WPINC.’/rss.php’); // path to include script
$feed = fetch_rss($fbrss); // specify feed url
$items = array_slice($feed->items, 0, 1); // specify first and last item
if (!empty($items)) :
foreach ($items as $item) : $dat = $item['pubdate']; ?>
<!–?php echo $cont = $item['description']; ?>–>
Updated on <!–?php echo date(‘Y-m-d’, strtotime($dat)); ?>–>
<!–?php endforeach; ?>–>
<!–?php endif; ?>–>
عن الكاتب :
Mhran alzaro
مهندس حاسوب من فلسطين متخصص في كتابة وصياغة جديد التكنلوجيا وتطبيقات الحاسوب
ليست هناك تعليقات:
إرسال تعليق