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

2019-07-17 06:06发布

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条回答
女痞
2楼-- · 2019-07-17 06:18

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";
查看更多
登录 后发表回答