We have built our main Aloashbei class in the previous post. Now we will extend it to locate any GrameenPhone number. But currently, as a developer you can only track your number for testing purpose.
File Structure:
- class.Aloashbei.php
- class.AloashbeiLBS.php
- location.php
- includes/WebService_Aloashbei_LBS_WS.wsdl
[sourcecode language=”php”]
<?php
//file: class.AloashbeiLBS.php
include_once ‘class.Aloashbei.php’;
/**
* Description of class
*
* @author Tareq Hasan
* @link http://tareq.weDevs.com
*/
class AloashbeiLBS extends Aloashbei
{
/**
* The mobile number that to be located
*
* @var string
*/
private $msisdn;
/**
* Set’s user’s user id and password
*
* @param string $user_id registered user id
* @param string $password registered password
*/
function __construct($user_id, $password)
{
parent::__construct($user_id, $password);
$this->soap = new SoapClient(‘includes/WebService_Aloashbei_LBS_WS.wsdl’);
}
/**
* Retreives current mobile location
*
* @param string $number mobile number
* @return object location details:
*/
function getLocation($number)
{
$this->msisdn = $number;
$this->auth = array(
‘registrationID’ => $this->registrationID,
‘password’ => $this->password,
‘msisdn’ => $this->msisdn
);
$result = $this->soap->requestLocation(array(‘LBSRequest’ => $this->auth));
return $result;
}
}
?>
[/sourcecode]
So we have “class.Aloashbei.php” and “class.AloashbeiLBS.php”. Now we need to get the wsdl file. Grab the file from here and change the file with the help of the previous post instruction.
Using the class:
[sourcecode language=”php”]
<?php
//file: location.php
include_once ‘class.AloashbeiLBS.php’;
$user_id = ‘********’;
$password = ‘*******’;
$dev_phone_no = ‘88017********’;
$lbs = new AloashbeiLBS($user_id, $password);
try
{
$result = $lbs->getLocation($number);
echo $latitude = $result->LBSResponse->Latitude;
echo $longitude = $result->LBSResponse->Longitude;
} catch (Exception $exc)
{
var_dump($exc);
}
?>
[/sourcecode]
If that scripts runs successfully, you will get the longitude and latitude of your phone number. But currently GP’s server is down, so I was not able test it before posting. But this code should surely work fine.
Visualize with google maps API:
We will pass the the longitude and latitude to the javascript variable, and it will show your current position graphically đ
[sourcecode language=”html”]
<!– file: location.php —>
<!DOCTYPE html>
<html>
<head>
<title>Aloashbei Location locator and visualize with google maps API: Tareq Hasan</title>
<style type="text/css">
html { height: 100% ; text-align: center;}
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas{
width: 500px;
height: 400px;
margin: 10px auto;
text-align: left;
}
</style>
<script type="text/javascript">
function initialize()
{
var latitude = <?php echo $latitude ?>;
var longitude = <?php echo $longitude ?>;
var myLatlng = new google.maps.LatLng(latitude, longitude);
var contentString = ‘You are here, honey!!!’ + ‘<br>’ +
‘Latitude: ‘ + latitude + ‘<br>’ +
‘Longitude: ‘ + longitude;
var infowindow = new google.maps.InfoWindow({
content: contentString,
position: myLatlng
});
var myOptions = {
zoom: 12,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
infowindow.open(map);
}
function loadScript()
{
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
document.body.appendChild(script);
}
window.onload = loadScript;
</script>
</head>
<body>
<div id="map_canvas"></div>
</body>
</html>
[/sourcecode]
If everything goes right, you will see a page like this:
Happy locating phone’s and don’t get beat đ
not working đ
err messege
object(SoapFault)#3 (9) { ["message:protected"]=> string(145) "Server did not recognize the value of HTTP Header SOAPAction: http://www.grameenphone.com/playground/WebService_Aloashbei_LBS_WS/requestLocation." ["string:private"]=> string(0) "" ["code:protected"]=> int(0) ["file:protected"]=> string(52) "/home/pqsofts1/public_html/kk/class.AloashbeiLBS.php" ["line:protected"]=> int(52) ["trace:private"]=> array(3) { [0]=> array(4) { ["function"]=> string(6) "__call" ["class"]=> string(10) "SoapClient" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(15) "requestLocation" [1]=> array(1) { [0]=> array(1) { ["LBSRequest"]=> array(3) { ["registrationID"]=> string(11) "shemulworld" ["password"]=> string(8) "shemul22" ["msisdn"]=> NULL } } } } } [1]=> array(6) { ["file"]=> string(52) "/home/pqsofts1/public_html/kk/class.AloashbeiLBS.php" ["line"]=> int(52) ["function"]=> string(15) "requestLocation" ["class"]=> string(10) "SoapClient" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> array(1) { ["LBSRequest"]=> array(3) { ["registrationID"]=> string(11) "shemulworld" ["password"]=> string(8) "shemul22" ["msisdn"]=> NULL } } } } [2]=> array(6) { ["file"]=> string(42) "/home/pqsofts1/public_html/kk/location.php" ["line"]=> int(14) ["function"]=> string(11) "getLocation" ["class"]=> string(12) "AloashbeiLBS" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> NULL } } } ["faultstring"]=> string(145) "Server did not recognize the value of HTTP Header SOAPAction: http://www.grameenphone.com/playground/WebService_Aloashbei_LBS_WS/requestLocation." ["faultcode"]=> string(11) "soap:Client" ["detail"]=> string(0) "" }
Probably you didn’t read my post completely, I said the serer is down for around 2/3 days. It doesn’t work here either đ
oh sorry …i thought server up (http://masnun.com/aloashbei/location/get this is running so)
shemul vai, apni to error code er moddhe apnar password o diye diyechen. even ekhono ei password e use kortesen. Please change it for your security. ami apnar username & password dia login kore deklam successfully login o holo. sorry for that. đ
thanks….pass changed !!
āĻāĻŽāĻŋ āĻāĻ āĻā§āĻĄ āĻā§āĻ˛ā§ āĻĒā§āĻ°ā§āĻĒā§āĻ°āĻŋ āĻŦā§āĻāĻ¤ā§ āĻĒāĻžāĻ°āĻŋ āĻ¨āĻžāĻāĨ¤ āĻāĻĒāĻ¨āĻŋ āĻ¯āĻĻāĻŋ āĻāĻŽāĻžā§ āĻāĻāĻā§ āĻšā§āĻ˛ā§āĻĒ āĻāĻ°āĻ¤ā§āĻ¨ āĻāĻžāĻ˛ā§ āĻšāĻ¤ā§āĨ¤ āĻāĻŽāĻžāĻ° āĻŽā§āĻāĻ˛ āĻ āĻāĻĒāĻ¨āĻŋ āĻāĻ āĻŦāĻŋāĻˇā§ā§āĻ° āĻāĻāĻāĻŋ āĻāĻŋāĻāĻā§āĻ°āĻŋā§āĻžāĻ˛ āĻĒāĻžāĻ āĻžāĻ¤ā§ āĻĒāĻžāĻ°ā§āĻ¨āĨ¤ āĻ āĻ¨ā§āĻ āĻāĻĒāĻāĻ¤ āĻšāĻŦāĨ¤
working ple….?
āĻāĻŽāĻŋ āĻāĻ āĻā§āĻĄ āĻā§āĻ˛ā§ āĻĒā§āĻ°ā§āĻĒā§āĻ°āĻŋ āĻŦā§āĻāĻ¤ā§ āĻĒāĻžāĻ°āĻŋ āĻ¨āĻžāĻāĨ¤ āĻāĻĒāĻ¨āĻŋ āĻ¯āĻĻāĻŋ āĻāĻŽāĻžā§ āĻāĻāĻā§ āĻšā§āĻ˛ā§āĻĒ āĻāĻ°āĻ¤ā§āĻ¨ āĻāĻžāĻ˛ā§ āĻšāĻ¤ā§āĨ¤ āĻāĻŽāĻžāĻ° āĻŽā§āĻāĻ˛ āĻ āĻāĻĒāĻ¨āĻŋ āĻāĻ āĻŦāĻŋāĻˇā§ā§āĻ° āĻāĻāĻāĻŋ āĻāĻŋāĻāĻā§āĻ°āĻŋā§āĻžāĻ˛ āĻĒāĻžāĻ āĻžāĻŦā§āĻ¨ āĻĻā§āĻžāĻāĻ°ā§ āĻāĻŋ āĨ¤ step by step āĨ¤ āĻ āĻ¨ā§āĻ āĻāĻĒāĻāĻ¤ āĻšāĻŦ āĨ¤
Teraq vi ai 3ta file ki name save korb & database lagbakina ?
please I don’t understand how to use these codes and trace my lost phone. can you please help me my phone number is 01757639992
amaky aktu help korben plz,
ame amar loceton janty casilam,
ame kothai asi ba kon tawar a asi plz help me