I wrote a PHP
script to retrieve my Google reviews and it works fine on my Wamp server. However when I moved it to my actual host I get this error:
Warning: file_get_contents(https://maps.googleapis.com/maps/api/place/details/json?reference=CoQBeAAAAK9bAE7g15Db0Xl4lmd371L8qLBpPHitJl7iI9GT6LYS0BheLRQZzvKXqNHevt08DH0fB7inlvcLby83yUSjzNeH5-n41HxtC60tYG9bE-B15PbShGHnQpy3wsvOoOsRtjmOCnEiaSmlsSWgM2hypXcEeHjh2NiFSXVbEo8pVTRXEhCZSqsHiAEWHhOflDaqXP9oGhQU8WS8PRwxFf7IaiPLWfxaA69csw&sensor=true&key=mykey) [function.file-get-contents]: failed to open stream: Permission denied in /home/www/advancedcomputing.us/reviews.php on line 8
I set permissions to 777 on reviews.php, but still same error. Obviously it's storing the data in a file that I don't have access to, but I have no idea which file that is. Any help would be appreciated.
Here is the code:
<style>
.text{font-size:8pt;color:black;font-weight:normal;font-family:arial}
.name{font-size:10pt;color:black;font-weight:bold;font-family:arial}
</style>
<?php
$url = "https://maps.googleapis.com/maps/api/place/details/json?reference=CoQBeAAAAK9bAE7g15Db0Xl4lmd371L8qLBpPHitJl7iI9GT6LYS0BheLRQZzvKXqNHevt08DH0fB7inlvcLby83yUSjzNeH5-n41HxtC60tYG9bE-B15PbShGHnQpy3wsvOoOsRtjmOCnEiaSmlsSWgM2hypXcEeHjh2NiFSXVbEo8pVTRXEhCZSqsHiAEWHhOflDaqXP9oGhQU8WS8PRwxFf7IaiPLWfxaA69csw&sensor=true&key=mykey";
//$jsonfile= file_get_contents($url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Language: en-us'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$jsonfile = curl_exec($ch);
curl_close($ch);
$data = json_decode($jsonfile);
$data = json_decode($jsonfile);
echo "<table cellpadding=0 cellspacing=0 width=250 border=0 bgcolor=white><tr><td align=center valign=bottom><a href=https://plus.google.com/114172317884481430965/about?hl=en style=color:blue;font-size:8pt;font-family:arial;>see all reviews</a></td></tr><tr><td height=5></td></tr>";
for($x=0;$x<sizeof($data->result->reviews);$x++){
echo "<tr>";
echo "<td class=name class=text style=padding-left:15px;>";
echo $data->result->reviews[$x]->author_name;
echo " ";
echo date("m-d-Y", $data->result->reviews[$x]->time);
echo "</td></tr><tr><td class=text style=padding-left:15px;>";
if($data->result->reviews[$x]->rating==5){echo "<img src=star.png><img src=star.png><img src=star.png><img src=star.png><img src=star.png>";}
if($data->result->reviews[$x]->rating==4){echo "<img src=star.png><img src=star.png><img src=star.png><img src=star.png>";}
if($data->result->reviews[$x]->rating==3){echo "<img src=star.png><img src=star.png><img src=star.png>";}
echo "</td></tr><tr><td class=text style=padding-left:15px;>";
echo $data->result->reviews[$x]->text;
echo "</td></tr>";
echo "<tr><td height=15></td></tr>";
}
?>
</table>