I want to get feeds from here http://laimoon.com/feed/jobs?search=female,arts&locations=2 If i directly browse this page in browser it show feed, also If i use this code in my local host which is on windows
$xml=simplexml_load_file("http://laimoon.com/feed/jobs?search=female,arts&locations=2");
print_r($file_contents);
OR
$file_contents = file_get_contents('http://laimoon.com/feed/jobs?search=female,arts&locations=2')
print_r($xml);
Both works fine
But if i use this code in my linux live server then it shows this error for file_get_contents()
Warning: file_get_contents(http://laimoon.com/feed/jobs?search=female,arts&locations=2): failed to open stream :HTTP request failed! HTTP/1.1 500 Internal Server Error
And this error for simplexml_load_file()
Warning: simplexml_load_file(http://laimoon.com/feed/jobs?search=female,arts&locations=2): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error
Thanks in advance :)
Finally i got my expected results, I'd just enable curl_setopt($ch, CURLOPT_POST, true);
in curl link and i got my result but there is one more problem that is now solved...
After this i load that xml data using simplexml_load_string($ret);
but it were not reads the CDATA then i add just two more parameters
simplexml_load_string($ret,'SimpleXMLElement', LIBXML_NOCDATA);
Then i got my expected result... Here is my complete code
$header = array('Content-Type:application/xml', 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1');
$ch = curl_init();
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate,sdch');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_HEADER, $header);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201");
curl_setopt($ch, CURLOPT_URL, "http://laimoon.com/feed/jobs?search=female,arts&locations=2");
curl_setopt($ch, CURLOPT_POSTFIELDS, $loginFields);
$ret = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($ret,'SimpleXMLElement', LIBXML_NOCDATA);
$chl = $xml->children()->children();
$items = $chl->item;
foreach($items as $item){
echo (string)$item->title."</br>";
echo (string)$item->description."</br>";
echo (string)$item->pubDate."</br>";
echo (string)$item->link."</br>";
}
Thanks @Mike W