Welcome Guest, Not a member yet? Register   Sign In
Try to make Amazon Library -- Error "Trying to get property of non-object"
#1

[eluser]onecode[/eluser]
Hello, i'm trying to make my own amazon web service library for associates program. I have "some" problem when i try to parse xml data.This is my code :

Code:
$url = 'http://ecs.amazon.com/blablabla';
$url = trim($url);
$content    = file_get_contents($url);
$xmlstr        = simplexml_load_string($content);
$item        = $xmlstr->Items->Item;

echo $item->EditorialReviews->EditorialReview->Content;

I've got a "Trying to get property of non-object" error here. But if i try another data from xml, all fine no error at all, such as Title and ASIN.

And one more thing...This error just happen when i'm doing a looping.

need help please :red:
#2

[eluser]onecode[/eluser]
i'm using a same code with same way in Joomla and Wordpress and all working fine...nothing error...just in here (Codeigniter 1.7.1) i've got this error... "Trying to get property of non-object"

what happen with this code? or maybe what happen with CI?
#3

[eluser]Aken[/eluser]
Don't know the solution to your problem, but I can tell you that you should use cURL functions instead of file_get_contents - it's safer.
#4

[eluser]pistolPete[/eluser]
I'd rather use simplexml_load_file:
Code:
$xmlstr = simplexml_load_file($url);




Theme © iAndrew 2016 - Forum software by © MyBB