Skip to content

Commit

Permalink
support cookie file format from browser request cookie param
Browse files Browse the repository at this point in the history
  • Loading branch information
Anisan committed Feb 27, 2023
1 parent 8a18610 commit 341cc00
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions modules/google_location/google_location.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,18 @@ public function getLocation($cookie_file) {
public function getLocationData($cookie_file) {
$url = 'https://www.google.com/maps/rpc/locationsharing/read?authuser=0&hl='.SETTINGS_SITE_LANGUAGE.'&gl='.SETTINGS_SITE_LANGUAGE.'&pb=';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
$fp = fopen($cookie_file, 'r');
$data = fgets($fp);
fclose($fp);
if ($data[0]=='#'){
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
}
else{
$headers = array();
$headers[] = 'Cookie: '.$data;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_HEADER, 1);
Expand Down

0 comments on commit 341cc00

Please sign in to comment.