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

拜拜、爱过 提交于 2020-01-15 05:13:05

问题


Does anybody know how to find a company's CID and/or LRD using the Google Places API?

The best solution I've come up with so far is this:

  1. Go to https://maps.google.com and search for the business
  2. Find the data parameter in the browser's URL and extract the component that matches this pattern: 0x[HEX_CODE1]:0x[HEX_CODE2]
  3. The 2-part number we just extracted is the company's LRD. Now, take HEXCODE_2 from that number and convert the hex to decimal. This gives us the company's CID.

Obviously this process isn't officially supported by Google, and wouldn't scale well if I needed to do it for many businesses. Does anybody have a better method?


回答1:


Read this article to obtain the CID: How to get the cid in the Google Place URL?

Two API requests and you'll have the CID of a business programmatically.

EDIT ----------

The LRD is CID in hexadecimal. You can use this function to:

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;
}

So you can build the Google Review Url like this:

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


来源:https://stackoverflow.com/questions/38579952/google-places-api-find-a-companys-cid-and-lrd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!