问题
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:
- Go to https://maps.google.com and search for the business
- Find the
data
parameter in the browser's URL and extract the component that matches this pattern:0x[HEX_CODE1]:0x[HEX_CODE2]
- 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