I am using below code to find Google reviews for property. What I am trying to do is, I am fetching review for property then I will compare it with old review of that property (which is in the DB). If it is greater than the system's property, then it sends email.
This file is run for every hour(as a cron file) and i enable the billing in Google API, so max limit is 1,50,000.
But for some reason API does not return the exact count of reviews.
For example:
I run this file for the one property which has 4 reviews, but API returns 0 for 2 or 3 times then after some time it returns 4 reviews.
I don't know the reason behind it. I also noticed that we can see the reviews on google search page and in Google+. Same you can write reviews in multiple places, like in Google+ and in Google Map.
And to check reviews, I am using google plus url. So is it possible that the review does exist, but in another area(like in Google search page but not in Google+)?
/* call api to get review count of Google */
$url = "https://maps.googleapis.com/maps/api/place/details/json?";
$params = array(
"placeid" => $google_place_id,
"key" => $google_api_key
);
$url .= http_build_query($params);
$resjson = file_get_contents($url);
$msg = $resjson;
Yii::log($msg,'info', 'application');
$resjson = json_decode($resjson,true);
$review_count = $resjson['result']['user_ratings_total']=='' ? 0 : $resjson['result']['user_ratings_total'];
/* If review is greater than 0 then check old review and if it's not same then send email */
if($review_count>0)
{
if(sizeof($ressql)>0)
{
/* if google plus review is greater then system's google+ review then send email */
if($review_count>trim($ressql[0]['google_plus_review']))
{
$this->send_googleplusmail($prop_id);
$msg = "Google+ Review for property id (Mail Sent):".$prop_id." , New Review:$review_count, Old Review: ".$ressql[0]['google_plus_review'];
Yii::log($msg,'info', 'application');
}
}
}
$sql=" INSERT INTO tbl_review_alert (propertyid, google_plus_review) VALUES ";
$sql.="('{$prop_id}','{$review_count}')";
$sql.=" ON DUPLICATE KEY UPDATE propertyid= {$prop_id},google_plus_review= {$review_count}";
$this->insert_review($sql);
My Question is:
(1) Is it possible that the review does exist, but in another area(like in Google search page but not in Google+)? If yes, then in this case can i obtain the URL where review is posted?
(2) Are all of the reviews are sync in Google?
(3) Or i am doing something wrong in my code?
https://plus.google.com/101511264527346460079/about
andhttps://www.google.co.in/webhp?ie=utf-8&oe=utf-8&gws_rd=cr&ei=clA-VeieGIORuQSj54DwCw#q=The+Kensington+665+Washington+St+Boston%2C+MA+02111
you can see that on google+ there is no review. but in google search, you can see that there is 43 Google reviews for this property. – Mensaluser_ratings_total
parameter. Which returns total no. of reviews. – Mensal