在Google上查找商家页面的CID和LRD

时间:2017-01-08 05:34:56

标签: javascript google-maps google-places-api google-my-business-api

我想知道如何在Google上找到特定商家页面的LRD和CID。

我尝试构建的示例网址如下

https://www.google.com/#q=takeout+banani&lucid="CID"&lrd=0x3755c7120ec9e20f:0x8889d4d79e711995,3

到目前为止我发现的是找不到CID和LRD的直接方法。

我必须进行两次API调用才能获得CID,如下所示,

"url": "https://maps.google.com/?cid=4839020573042712727",

但是在api中是否有任何其他方式或指向FIELD,如下面的place_id?

"place_id": "ChIJrQFQG6PHVTcRl6AErZKnJ0M"

现在来到LRD部分,我如何找到它?在此详细信息API中

https://maps.googleapis.com/maps/api/place/details/json?reference="Referense key from place request api"&sensor=true&key="Your API Key"

LRD也没有直接字段。

那么我怎么能在这些格式中找到或找到LRD 0x [HEX_CODE1]:0x [HEX_CODE2]

我将下面的stackoverflow问题链接为参考。

How to get the cid in the Google Place URL?

Google Places API - Find a company's CID and LRD

1 个答案:

答案 0 :(得分:0)

阅读此答案以获取CID: How to get the cid in the Google Place URL?

两个API请求,您将以编程方式获得业务的CID。

编辑----------

LRD是十六进制的CID。您可以使用此功能:

function dec2hex($number)
{
    $hexvalues = array('0','1','2','3','4','5','6','7',
               '8','9','A','B','C','D','E','F');
    $hexval = '';
     while($number != '0')
     {
        $hexval = $hexvalues[bcmod($number,'16')].$hexval;
        $number = bcdiv($number,'16',0);
    }
    return $hexval;
}

因此,您可以像这样构建Google Review Url:

$business_url = "https://www.google.com/search?q=NAMEOFBUSINESS&ludocid=YOURCID#lrd=0x0:0xYOURHEXCID,1";