BRT2010 Posted April 13, 2010 Share Posted April 13, 2010 Hi guys, I need to write a PHP function that would connect to google maps, send over mcc/mnc/lac/cid and receive lat/long coordinates. I have found sort of an api here http://code.google.com/intl/ru/apis/gears/geolocation_network_protocol.html and here http://www.witracks.com.br/gmaps.txt Thanks guys! Quote Link to comment Share on other sites More sharing options...
Jax2 Posted April 13, 2010 Share Posted April 13, 2010 Not to sound rude, but where's the question? If you're simply looking for someone to write the script for you, you should put a request in the php freelance board. This section is for people who write their own scripts and need help with them ... Do you have something written that's not working? Quote Link to comment Share on other sites More sharing options...
BRT2010 Posted April 13, 2010 Author Share Posted April 13, 2010 Not to sound rude, but where's the question? If you're simply looking for someone to write the script for you, you should put a request in the php freelance board. This section is for people who write their own scripts and need help with them ... Do you have something written that's not working? Well, i have found a script: <?php $data = "\x00\x0e". // Function Code? "\x00\x00\x00\x00\x00\x00\x00\x00". //Session ID? "\x00\x00". // Contry Code "\x00\x00". // Client descriptor "\x00\x00". // Version "\x1b". // Op Code? "\x00\x00\x00\x00". // MNC "\x00\x00\x00\x00". // MCC "\x00\x00\x00\x03". "\x00\x00". "\x00\x00\x00\x00". //CID "\x00\x00\x00\x00". //LAC "\x00\x00\x00\x00". //MNC "\x00\x00\x00\x00". //MCC "\xff\xff\xff\xff". // ?? "\x00\x00\x00\x00" // Rx Level? ; if ($_REQUEST["myl"] != "") { $temp = split(":", $_REQUEST["myl"]); $mcc = substr("00000000".dechex($temp[0]),-; $mnc = substr("00000000".dechex($temp[1]),-; $lac = substr("00000000".dechex($temp[2]),-; $cid = substr("00000000".dechex($temp[3]),-; } else { $mcc = substr("00000000".$_REQUEST["mcc"],-; $mnc = substr("00000000".$_REQUEST["mnc"],-; $lac = substr("00000000".$_REQUEST["lac"],-; $cid = substr("00000000".$_REQUEST["cid"],-; } $init_pos = strlen($data); $data[$init_pos - 38]= pack("H*",substr($mnc,0,2)); $data[$init_pos - 37]= pack("H*",substr($mnc,2,2)); $data[$init_pos - 36]= pack("H*",substr($mnc,4,2)); $data[$init_pos - 35]= pack("H*",substr($mnc,6,2)); $data[$init_pos - 34]= pack("H*",substr($mcc,0,2)); $data[$init_pos - 33]= pack("H*",substr($mcc,2,2)); $data[$init_pos - 32]= pack("H*",substr($mcc,4,2)); $data[$init_pos - 31]= pack("H*",substr($mcc,6,2)); $data[$init_pos - 24]= pack("H*",substr($cid,0,2)); $data[$init_pos - 23]= pack("H*",substr($cid,2,2)); $data[$init_pos - 22]= pack("H*",substr($cid,4,2)); $data[$init_pos - 21]= pack("H*",substr($cid,6,2)); $data[$init_pos - 20]= pack("H*",substr($lac,0,2)); $data[$init_pos - 19]= pack("H*",substr($lac,2,2)); $data[$init_pos - 18]= pack("H*",substr($lac,4,2)); $data[$init_pos - 17]= pack("H*",substr($lac,6,2)); $data[$init_pos - 16]= pack("H*",substr($mnc,0,2)); $data[$init_pos - 15]= pack("H*",substr($mnc,2,2)); $data[$init_pos - 14]= pack("H*",substr($mnc,4,2)); $data[$init_pos - 13]= pack("H*",substr($mnc,6,2)); $data[$init_pos - 12]= pack("H*",substr($mcc,0,2)); $data[$init_pos - 11]= pack("H*",substr($mcc,2,2)); $data[$init_pos - 10]= pack("H*",substr($mcc,4,2)); $data[$init_pos - 9]= pack("H*",substr($mcc,6,2)); if ((hexdec($cid) > 0xffff) && ($mcc != "00000000") && ($mnc != "00000000")) { $data[$init_pos - 27] = chr(5); } else { $data[$init_pos - 24]= chr(0); $data[$init_pos - 23]= chr(0); } $context = array ( 'http' => array ( 'method' => 'POST', 'header'=> "Content-type: application/binary\r\n" . "Content-Length: " . strlen($data) . "\r\n", 'content' => $data ) ); $xcontext = stream_context_create($context); $str=file_get_contents("http://www.google.com/glm/mmap",FALSE,$xcontext); if (strlen($str) > 10) { $lat_tmp = unpack("l",$str[10].$str[9].$str[8].$str[7]); $lat = $lat_tmp[1]/1000000; $lon_tmp = unpack("l",$str[14].$str[13].$str[12].$str[11]); $lon = $lon_tmp[1]/1000000; echo "Lat=$lat <br> Lon=$lon"; } else { echo "Not found!"; } ?> but somehow I can't really understand how to work with it, where do I insert mcc/mnc/lac/cid information for it to echo out lat/long. but if you think this script is doomed and a new one needs to be written, could the moderators move this topic to the freelance section? Quote Link to comment Share on other sites More sharing options...
mrhenniger Posted April 13, 2010 Share Posted April 13, 2010 There is no quick easy-to-use php function for Google Maps. It took me a while to learn integrated Google Maps, but they do have it well documented and there is a Google Group where you can post your questions. BTW... I found it took some education in Javascript before I became good at it. Quote Link to comment Share on other sites More sharing options...
mattal999 Posted April 13, 2010 Share Posted April 13, 2010 Well here is where you set the variables that you listed: $mcc = substr("00000000".$_REQUEST["mcc"],-; $mnc = substr("00000000".$_REQUEST["mnc"],-; $lac = substr("00000000".$_REQUEST["lac"],-; $cid = substr("00000000".$_REQUEST["cid"],-; Just change the $_REQUEST["xxx"] to $_GET["xxx"] or $_POST["xxx"] to suit your needs. Quote Link to comment Share on other sites More sharing options...
BRT2010 Posted April 13, 2010 Author Share Posted April 13, 2010 Well here is where you set the variables that you listed: $mcc = substr("00000000".$_REQUEST["mcc"],-; $mnc = substr("00000000".$_REQUEST["mnc"],-; $lac = substr("00000000".$_REQUEST["lac"],-; $cid = substr("00000000".$_REQUEST["cid"],-; Just change the $_REQUEST["xxx"] to $_GET["xxx"] or $_POST["xxx"] to suit your needs. Replaced, yet still nothing. If I'm right, I had to run it like that http://localhost/mobi/test.php?mcc=250&mnc=02&lac=4000&cid=9164 by the way, here's a Python 2 script that actually works! net, cid, lac = 25002, 9164, 4000 import urllib # net = MCC 250 & MNC 02 a = '000E00000000000000000000000000001B0000000000000000000000030000' b = hex(cid)[2:].zfill( + hex(lac)[2:].zfill( c = hex(divmod(net,100)[1])[2:].zfill( + hex(divmod(net,100)[0])[2:].zfill( string = (a + b + c + 'FFFFFFFF00000000').decode('hex') try: data = urllib.urlopen('http://www.google.com/glm/mmap',string) r = data.read().encode('hex') if len(r) > 14: print float(int(r[14:22],16))/1000000, float(int(r[22:30],16))/1000000 else: print 'no data in google' except: print 'connect error' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.