Jump to content

april2008

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

april2008's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. this is the code i have <? Function feedMe($feed) { // Use cURL to fetch text $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $feed); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_USERAGENT, $useragent); $rss = curl_exec($ch); curl_close($ch); // Manipulate string into object $rss = simplexml_load_string($rss); $siteTitle = $rss->channel->title; echo "<h1>".$siteTitle."</h1>"; echo "<hr />"; $cnt = count($rss->channel->item); for($i=0; $i<$cnt; $i++) { $url = $rss->channel->item[$i]->link; $title = $rss->channel->item[$i]->title; $desc = $rss->channel->item[$i]->description; echo '<h3><a href="'.$url.'">'.$title.'</a></h3>'.$desc.''; } } feedMe("http://twitter.com/statuses/user_timeline/44045750.rss"); ?>
  2. I am trying to get .rss working with the following url http://www.studiolounge.net/2009/03/28/php-and-curl/ but i got this error Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 5: parser error : Opening and ending tag mismatch: META line 2 and HEAD in C:\Apache2.2\htdocs\emedia\twitter_rss3.php on line 16 currently using php5.0 and apache2.2
  3. Problem solve just add in the code below after curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); to detect the proxy setting curl_setopt($ch, CURLOPT_PROXY, "http://xxx.xxx.xxx.xxx:8080"); curl_setopt($ch, CURLOPT_PROXYPORT, 8080); curl_setopt ($ch, CURLOPT_PROXYUSERPWD, "username:password"); thanks everyone
  4. thanks for the help, even though my problem still not solve yet.
  5. Previously, i had post up a topic http://www.phpfreaks.com/forums/index.php/topic,245433.0.html, but couldn't solve the problem. i not sure is it my configuration having problem.....please help!! thanks in advance
  6. do i need to add any extension in C:\WINDOWS\system32?
  7. what configuration i actually need to set?can u please guide me? can i know what is ur configuration for php.ini and apache config? thanks
  8. MadTechie, how come my result is different with redarrow ??
  9. ok. i off the firewall and tested the code u given. this is the output ------------------------------ array(19) { ["url"]=> string(38) "http://www.dpreview.com/feeds/news.xml" ["http_code"]=> int(0) ["header_size"]=> int(0) ["request_size"]=> int(0) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0) ["namelookup_time"]=> float(0) ["connect_time"]=> float(0) ["pretransfer_time"]=> float(0) ["size_upload"]=> float(0) ["size_download"]=> float(0) ["speed_download"]=> float(0) ["speed_upload"]=> float(0) ["download_content_length"]=> float(0) ["upload_content_length"]=> float(0) ["starttransfer_time"]=> float(0) ["redirect_time"]=> float(0) } ------------------------------
  10. sorry for misunderstanding...i already turn them off. but still display as a blank page :-\ so i refer to the PHP Installation & Configuration section, this guy http://www.phpfreaks.com/forums/index.php/topic,242449.0.html having the same problem as mine, but nobody have solve it
  11. i tried to safe_mode = On, it still display a blank page. if open_basedir = On, i got the error below Warning: Unknown: open_basedir restriction in effect. File(C:/Apache2.2/htdocs/testing.php) is not within the allowed path(s): (1) in Unknown on line 0 Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0 Fatal error: Unknown: Failed opening required 'C:/Apache2.2/htdocs/testing.php' (include_path='.;C:\php5\pear') in Unknown on line 0. by the way, is it safe to on safe mode and open_basedir?
  12. rebooted my pc. the page remain as blank. can i know what configuration do i need to make changes?
  13. ok.this is the code i had modify <? error_reporting(E_ALL); //$xml = file_get_contents('http://www.dpreview.com/feeds/news.xml'); // Use cURL to get the RSS feed into a PHP string variable. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,'http://www.dpreview.com/feeds/news.xml'); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $xml = curl_exec($ch); curl_close($ch); die($xml);//added for debugging //$xml = curl_exec($ch); //curl_close($ch); // Include the handy XML data extraction functions. include 'xml_regex.php'; // An RSS 2.0 feed must have a channel title, and it will // come before the news items. So it's safe to grab the // first title element and assume that it's the channel // title. $channel_title = value_in('title', $xml); // An RSS 2.0 feed must also have a link element that // points to the site that the feed came from. $channel_link = value_in('link', $xml); // Create an array of item elements from the XML feed. $news_items = element_set('item', $xml); foreach($news_items as $item) { $title = value_in('title', $item); $url = value_in('link', $item); $description = value_in('description', $item); $timestamp = strtotime(value_in('pubDate', $item)); $item_array[] = array( 'title' => $title, 'url' => $url, 'description' => $description, 'timestamp' => $timestamp ); } if (sizeof($item_array) > 0) { // First create a div element as a container for the whole // thing. This makes CSS styling easier. $html = '<div class="rss_feed_headlines">'; // Markup the title of the channel as a hyperlink. $html .= '<h2 class="channel_title">'. '<a href="'.make_safe($channel_link).'">'. make_safe($channel_title).'</a></h2><dl>'; // Now iterate through the data array, building HTML for // each news item. $count = 0; foreach ($item_array as $item) { $html .= '<dt><a href="'.make_safe($item['url']).'">'. make_safe($item['title']).'</a></dt>'; //$html .= '<dd>'.make_safe($item['description']); if ($item['timestamp'] != false) { $html .= '<br />'; //'<span class="news_date">['. //gmdate('H:i, jS F T', $item['timestamp']). //']</span>'; } //echo '</dd>'; // Limit the output to five news items. if (++$count == 10) { break; } } $html .= '</dl></div>'; echo $html; } function make_safe($string) { $string = preg_replace('#<!\[CDATA\[.*?\]\]>#s', '', $string); $string = strip_tags($string); // The next line requires PHP 5, unfortunately. //$string = htmlentities($string, ENT_NOQUOTES, 'UTF-8', false); // Instead, use this set of replacements in PHP 4. $string = str_replace('<', '<', $string); $string = str_replace('>', '>', $string); $string = str_replace('(', '&#40;', $string); $string = str_replace(')', '&#41;', $string); return $string; } $string = preg_replace('#<!\[CDATA\[.*?\]\]>#s', '', $string); ?> but it still display an empty page ???
  14. ok, i have remove the function file_get_contents. now the page display blank
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.