Facebook RSS won't return all posts from request...
Posted: Mon Jan 27, 2014 4:44 pm
UPDATE:
I have found that the problem is something about the server configuration, but I'm not sure what it is and am looking for a work around to the issue. I have two identical scripts running on two different hosting providers and one works correctly. I will give you both addresses so you can make comparisons and I hope you will see the issue I am missing that is causing this problem. You will notice what is wrong easily, the working script has 4 times as many posts data.
First the script with the issue:
uploaded to http://byethost.com/ a free hosting account, scripts need to work with these providers if possible.
http://webpresscreative.byethost24.com/test5.php
The working script uploaded to Godaddy a premium business account.
http://softnetwd.com/test5.php
The script is this one below:
I have an issue with this script, it works but there is a huge difference in the xml data from Facebook from loading a browser and looking at the xml doc and what the script gets from Facebook. When the script runs Facebook returns much less data but the xml doc is complete so its not timing out or any other error, just a lot less posts.
Got any ideas, header info missing or something? I can't think of what it may be, hope somebody else can...
Here is the script:
You can omit the database code areas and I have added in the last line to view results for testing...
Thanks!!
I have found that the problem is something about the server configuration, but I'm not sure what it is and am looking for a work around to the issue. I have two identical scripts running on two different hosting providers and one works correctly. I will give you both addresses so you can make comparisons and I hope you will see the issue I am missing that is causing this problem. You will notice what is wrong easily, the working script has 4 times as many posts data.
First the script with the issue:
uploaded to http://byethost.com/ a free hosting account, scripts need to work with these providers if possible.
http://webpresscreative.byethost24.com/test5.php
The working script uploaded to Godaddy a premium business account.
http://softnetwd.com/test5.php
The script is this one below:
I have an issue with this script, it works but there is a huge difference in the xml data from Facebook from loading a browser and looking at the xml doc and what the script gets from Facebook. When the script runs Facebook returns much less data but the xml doc is complete so its not timing out or any other error, just a lot less posts.
Got any ideas, header info missing or something? I can't think of what it may be, hope somebody else can...
Here is the script:
Code: Select all
<?php
//ini_set('display_errors', 'off');
function remote_file_size($url){
$data = get_headers($url, true);
if (isset($data['Content-Length']))
return (int) $data['Content-Length'];
}
$rss_date=date('Y-m-d\TH:i:sP');
$fb_page_id='626664130730204';
$rss_feed_url='http://www.facebook.com/feeds/page.php?format=atom10&id='.$fb_page_id;
$pg_name='facebook test page';
$pg_name=urlencode($pg_name);
$filesize=remote_file_size($rss_feed_url);
if($filesize > 0) {
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');
$xml = simplexml_load_file($rss_feed_url,NULL,LIBXML_NOCDATA);
$feed_info['id']=urlencode((string)$xml->id);
$feed_info['title']=urlencode((string)$xml->title);
foreach($xml->link as $var){
$links[$cnt]=urlencode((string)$var[href]);
$cnt++;}
$feed_info['link']=implode('|', $links);
$feed_info['updated']=urlencode((string)$xml->updated);
$feed_info['icon']=urlencode((string)$xml->icon);
$feed_info['logo']=urlencode((string)$xml->logo);
$cnt=0;
foreach($xml->entry as $entry_var) {
if(strlen((string)$entry_var->id) == 0){$id_ans='0';}else{
$id_ans=urlencode((string)$entry_var->id);}
$entry_data['id']=$entry_data['id'].$id_ans.'|';
$fb_wall['id'.$cnt]=$id_ans;
$entry_data['link']=$entry_data['link'].urlencode((string)$entry_var->link[href]).'|';
$fb_wall['link'.$cnt]=urlencode((string)$entry_var->link[href]);
$entry_data['title']=$entry_data['title'].urlencode((string)$entry_var->title).'|';
$fb_wall['title'.$cnt]=urlencode((string)$entry_var->title);
$entry_data['published']=$entry_data['published'].urlencode((string)$entry_var->published).'|';
$fb_wall['published'.$cnt]=urlencode((string)$entry_var->published);
$entry_data['updated']=$entry_data['updated'].urlencode((string)$entry_var->updated).'|';
$fb_wall['updated'.$cnt]=urlencode((string)$entry_var->updated);
$entry_data['name']=$entry_data['name'].urlencode((string)$entry_var->author->name).'|';
$fb_wall['name'.$cnt]=urlencode((string)$entry_var->author->name);
$entry_data['content']=$entry_data['content'].urlencode((string)$entry_var->content).'|';
$fb_wall['content'.$cnt]=urlencode((string)$entry_var->content);
//echo var_dump((string)$entry_var->content);
$cnt++;}
}
if($feed_info && $entry_data){
// removed db code
$cnt=0;
while(strlen($fb_wall['id'.$cnt]) > 0) {
$id=$fb_wall['id'.$cnt];
$link=$fb_wall['link'.$cnt];
$title=$fb_wall['title'.$cnt];
$published=$fb_wall['published'.$cnt];
$updated=$fb_wall['updated'.$cnt];
$name=$fb_wall['name'.$cnt];
$content=$fb_wall['content'.$cnt];
// removed db code
$cnt++;
}
}else{$rss_db='error';}
// below added to view result for testing:
$temps=explode('|', $entry_data['content']);$cnt=0;
foreach($temps as $var){echo '<hr>'.urldecode($var).'<hr>';}
//print_r($xml);
?>Code: Select all
$temps=explode('|', $entry_data['content']);$cnt=0;
foreach($temps as $var){echo '<hr>'.urldecode($var).'<hr>';}Thanks!!