简体   繁体   English

Google API中的评论

[英]Reviews in Google API

I am using below code to find Google reviews for property. 我正在使用下面的代码来查找Google对物业的评论。 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. 该文件每小时运行一次(作为cron文件),并且我在Google API中启用了结算功能,因此最大限额为1,50,000。

But for some reason API does not return the exact count of reviews. 但是由于某些原因,API不会返回确切的评论数。 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. 我为具有4条评论的一个属性运行此文件,但是API返回0表示2或3次,然后在一段时间后返回4条评论。

I don't know the reason behind it. 我不知道背后的原因。 I also noticed that we can see the reviews on google search page and in Google+. 我还注意到,我们可以在Google搜索页和Google+中看到评论。 Same you can write reviews in multiple places, like in Google+ and in Google Map. 同样,您可以在多个地方(例如Google+和Google Map)中撰写评论。

And to check reviews, I am using google plus url. 并查看评论,我使用的是Google加网址。 So is it possible that the review does exist, but in another area(like in Google search page but not in Google+)? 因此,该评论确实可能存在,但存在于另一个区域(例如Google搜索页中,但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+)? (1)该评论是否确实存在,但是存在于另一个区域(例如Google搜索页中,但Google+中不存在)? If yes, then in this case can i obtain the URL where review is posted? 如果是,那么在这种情况下,我可以获取张贴评论的URL吗?
(2) Are all of the reviews are sync in Google? (2)是否所有评论都已在Google中同步?
(3) Or i am doing something wrong in my code? (3)还是我的代码做错了什么?

I think I've spot where the problem is. 我想我已经找到问题所在了。

The reason why you can't see the existing reviews about that Place is that it seems that there're 2 google+ accounts for the same; 之所以看不到该地点的现有评论,是因为似乎有2个google +帐户用于同一地点; The only difference (at least the first I've noticed) is in the zip code, MA 02116 vs. MA 02111. 唯一的区别(至少我第一次注意到)是邮政编码MA 02116与MA 02111。

Take a look at: 看一眼:

https://plus.google.com/101511264527346460079/about https://plus.google.com/101511264527346460079/关于

and

https://plus.google.com/105917345931375838754/about https://plus.google.com/105917345931375838754/关于

As you can see, in the second one there are the same reviews you see in the search page 如您所见,在第二篇中,您在搜索页面中看到的评论相同

And by inserting the address "The Kensington, 665 Washington St, Boston, MA 02116, Stati Uniti" into the finder , I obtain a placeid different from the other one. 通过将地址“ The Kensington,665 Washington St,Boston,MA 02116,Stati Uniti”插入到取景器中 ,我得到了一个不同于另一个的Placeid。

Now by using this last one in 现在通过使用最后一个

$params = array(
    "placeid" => $google_place_id, // the new placeid here
    "key" => $google_api_key
);

I can then get the 5 reviews in the Place API json response. 然后,我可以在Place API json响应中获得5条评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM