DS9*_*DS9 8 php google-plus-one google-places-api
我使用下面的代码来查找Google对房产的评价.我想要做的是,我正在对财产进行审查,然后我会将其与该财产的旧审查(在数据库中)进行比较.如果它大于系统的属性,则它会发送电子邮件.
此文件每小时运行一次(作为cron文件),我在Google API中启用结算,因此最大限制为1,50,000.
但由于某种原因,API不会返回确切的评论数.例如:
我为具有4条评论的一个属性运行此文件,但API返回0 2或3次,然后在一段时间后返回4条评论.
我不知道背后的原因.我还注意到,我们可以在Google搜索页面和Google+中查看评论.同样,您可以在多个位置撰写评论,例如在Google+和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);
Run Code Online (Sandbox Code Playgroud)
我的问题是:
(1)评论是否可能存在,但在另一个领域(如Google搜索页面但不在Google+中)?如果是,那么在这种情况下我可以获得发布评论的URL吗?
(2)所有评论是否都在谷歌同步?
(3)或者我在代码中做错了什么?
我想我已经发现了问题所在.
你无法看到关于该地方的现有评论的原因是,似乎有两个谷歌+帐户相同; 唯一的区别(至少是我注意到的第一个)是邮政编码,MA 02116与MA 02111.
看一眼:
https://plus.google.com/101511264527346460079/about
和
https://plus.google.com/105917345931375838754/about
如您所见,在第二个中,您在搜索页面中看到的评论相同
通过将地址"The Kensington,665 Washington St,Boston,MA 02116,Stati Uniti"插入发现者,我获得了一个与另一个不同的地方.
现在使用最后一个
$params = array(
"placeid" => $google_place_id, // the new placeid here
"key" => $google_api_key
);
Run Code Online (Sandbox Code Playgroud)
然后我可以在Place API json响应中获得5条评论.