4

In Google local listings, there is a URL that can take a person directly to the pop-up window showing the reviews of a business. Here is an example:

https://www.google.com/search?q=Massage+Envy+-+Arrowhead&ludocid=12682026813239828050#lrd=0x872b682580f9e59b:0xafff9c31c3239e52,1

Each business location has a numeric ID in the URL (in the example, 12682026813239828050) as well as a hexadecimal representation of this number in the #lrd parameter.

I have all of the numeric IDs, and need to generate these URLs by determining how the hexadecmial segment is formed. For locations with IDs that can be represented in 16 hex characters, this is easy. The URL segment is simply 0x0:0x[hexstring] for example:

4134566830992571874 => 0x0:0x3960eea07d6cbe00

But when the number is too long, it is broken into two hex strings, and I can't determine the origin of the first one. I pulled in 2 examples:

14384749138104818286 => 0x872b0445e4ee5e9b:0xc7a0e5209fd81a6e
15716027411522919173 => 0x872b00074aa36265:0xda1a8ba9e8201b05

The SECOND hex string converts to a number that is CLOSE. In the examples:

c7a0e5209fd81a6e => 14384749138104818 (missing the last 3 digits)
da1a8ba9e8201b05 => 15716027411522918 (missing the last 3 digits and off by 1000)

Here is a site that is successfully converting them: https://pleper.com/index.php?do=tools&sdo=google_review_link&url=4134566830992571874

Can anyone help me determine the method by which these are being generated? If there is another stack site that would be better for this please direct me there as well. Thank you!

Jeff
  • 24,623
  • 4
  • 69
  • 78
  • 1
    Adding 0x0:0x[result of that function] to the url no longer works for the new review modal on google search. That will allow you to open the modal that shows all the review and the user can click write a review at the top but it won't open the review modal directly. Here is an example of the current lrd: lrd=0x6b12ae37b47f5b37:0x8eaddfcd1b32ca52,3,5 [google Sydney reviews](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=google%20syndey&*&lrd=0x6b12ae37b47f5b37:0x8eaddfcd1b32ca52,3,) – tech-e Mar 24 '17 at 18:15

4 Answers4

4

To answer the question. Here is the current breakdown of google lrd to leave a 5 star review:

#lrd=0x6b12ae37b47f5b37:0x8eaddfcd1b32ca52,3,5

Here is the break down as far as I know:

lrd = 
[ 0x6b12ae37b47f5b37 ] = Unknown. What does this number represent? 
: 
[ 0x8eaddfcd1b32ca52 ] = google cid converted to hex 
[ ,3 ] = The review type. 1 for reviews, 2 for write review, 3 also write     review
[ ,5 ] = The review rating to pre-fill on the modal

If you are looking for a solution to create a review link this may help. A solution to the problem would be to use to use the google places api. This will allow you to query a business place_id from the api and use it with the review link google allows you to use as a public review link like example below:

https://search.google.com/local/writereview?placeid= [place_id]

For more info on this link: Google review help

This still wouldn't allow you to get the actual link that google created on google search, or append the review rating to pre fill on the review modal like this example:

https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=google+syndey&*&lrd=0x6b12ae37b47f5b37:0x8eaddfcd1b32ca52,3,5

The solution to this problem can be solved with a curl request using the first link we created using the place_id and getting the return location from the response headers.

/* this is a php example curl */ 

$id = "ChIJN1t_tDeuEmsRUsoyG83frY4";

/* this will return the review url for a 
google place account. 
@param (string) $id = the google place_id 
@return (string|false) the google review url 
or false on error */ 
function getReviewUrl($id)
{ 
    $url = "https://search.google.com/local/writereview?placeid=" . $id; 

    /* we need to setup headers to show a user agent 
    to stop google from redirecting to a 404 because 
    the request is coming from a curl */ 
    $header = array(
        'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36'
    );

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_URL, $url);
    $out = curl_exec($ch);

    $location = false; 
    preg_match('/^(?:Location:(.*))$/mi', $out, $matches);
    if(isset($matches[1]))
    { 
        $location = $matches[1]; // this is the full review url
    }
    curl_close($ch);
    return $location; 
}

echo getReviewUrl($id);

This will return the full google review url and you can easily add the ",5" ending on it to pre fill the rating to 5 stars.

tech-e
  • 434
  • 5
  • 15
2

@2020

Google finally simplified the Review URL so we wouldn't have to convert the &lrd parameter into hex anymore. A bad hack.

Now all you need is the place_id parameter for the location and these URLs:

Robert Barrueco
  • 758
  • 5
  • 5
1

I ended up getting it to work using the "convert long integer to hex" function here: How to convert a huge integer to hex in php?

Turns out the URL also works if you use 0x0:0x[result of that function] instead of using the two-part one generated by Google. There is still definitely another URL that works, but I have this one working in the mean time. Thanks.

Community
  • 1
  • 1
Jeff
  • 24,623
  • 4
  • 69
  • 78
  • 2
    Adding 0x0:0x[result of that function] to the url no longer works for the new review modal on google search. That will allow you to open the modal that shows all the review and the user can click write a review at the top but it won't open the review modal directly. Here is an example of the current lrd: lrd=0x6b12ae37b47f5b37:0x8eaddfcd1b32ca52,3,5 [google sydney reviews](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=google%20syndey&*&lrd=0x6b12ae37b47f5b37:0x8eaddfcd1b32ca52,3,) – Ryan Mar 24 '17 at 23:14
-1

Simple search the place, in the google search, in the right side card, find the write review button, click, it and then copy the url above.

Miguel
  • 3,349
  • 2
  • 32
  • 28