I keep getting this error when I parse the trip advisor feed. Trying to pull up the username.
Catchable fatal error: Object of class stdClass could not be converted to string
Here's my code with the link to the feed.
<?php
function getCode($url)
{
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
$html=getCode("http://api.tripadvisor.com/api/partner/1.0/location/258705/reviews");
$json = json_decode($html);
$cnt=0;
foreach ($json as $item)
{
foreach($item as $row)
{
echo "Image Url:".$row->text."<br>";
echo "ID:".$row->id."<br>";
//username
foreach($row->user as $row1)
{
echo $row1."<br>";
}
}
echo "<br><br>";
}
?>
echo), you will get this error as string context needs strings to output (that can be object, but only those which implement_toString()which is not the case forstdClass.