You are here:  » Magicparser Not working with this link


Magicparser Not working with this link

Submitted by fraizor on Thu, 2016-09-01 14:00 in

as the title say
magicparser is not working with this link
{link saved}

Submitted by support on Thu, 2016-09-01 15:17

Hello fraizor,

Try setting a "browser" looking user-agent by adding the following code at the very top of your script;

   ini_set('user_agent','Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11');

...that may be all that's required, if still no joy if you could post your example code once more I'll check it out further for you...

Cheers,
David
--
MagicParser.com

Submitted by fraizor on Thu, 2016-09-01 19:28

thanks for fast replay
i will try this then feedback
but the wired thing is that it is working on the demo page but never works on the actual php
how so ?

Submitted by support on Fri, 2016-09-02 07:35

Hello fraizor,

The demo tools sets a user-agent overriding the default user-agent used by PHP, so that may be all it is..

Cheers,
David
--
MagicParser.com

Submitted by fraizor on Fri, 2016-09-02 09:25

hi
im still facing the same problem
what im doing wrong ?

{code saved}

Submitted by support on Fri, 2016-09-02 09:55

Hello fraizor,

The code worked fine for me, and also without specifying the user-agent. Please try the CURL equivalent using;

<?php
  
require("MagicParser.php");
  
$url "http://www.example.net/news_rss.php";
  
$ch curl_init($url);
  
curl_setopt($chCURLOPT_HEADER0);
  
curl_setopt($chCURLOPT_RETURNTRANSFER1);
  
$xml curl_exec($ch);
  
curl_close($ch);
  
MagicParser_parse("string://".$xml,"bbc","xml|RSS/CHANNEL/ITEM/");
  function 
bbc($record)
  {
    print 
$record["TITLE"];
  }
?>

(don't forget to change example.net to the domain name for your feed)

If still no output of each title, try dumping the XML , so where you have in the above code:

  $xml = curl_exec($ch);

...REPLACE with:

  $xml = curl_exec($ch);
  print $xml;exit();

That might reveal, for example, an HTML error message instead of the expected RSS response...

Cheers,
David
--
MagicParser.com