Beispiel #1
0
        static void TestAuthService()
        {
            L("Auth Service Testing");

            // Fetch ApplicationId and ApplicationSecret in your config file
            string applicationId     = "YOUR_APP_ID";
            string applicationSecret = "YOUR_APP_SECRET";

            GlobeLabs api = new GlobeLabs(applicationId, applicationSecret);

            string code = "CODE_PUSHED_BY_GLOBE_SYSTEM";

            // 1. Retrieve AccessToken based on Code.
            var result = api.Authorize(code);

            // Save the result to database, subscriber and access_token pair

            // Uncomment to get return values
            //string accessToken = result.Result.AccessToken;
            //string mobile = result.Result.SubscriberNumber;

            // 2. Generate Url to paste on your web browser
            //var dialogUrl = api.GetAuthLoginUrl();

            L("Data: " + result);
        }
Beispiel #2
0
        static void TestPaymentService(string accessToken)
        {
            L("Payment Service Testing");
            GlobeLabs api = new GlobeLabs(accessToken);

            var payload = new PaymentPayload
            {
                Amount        = "0.00",
                Description   = "Charging API",
                Number        = "9171234567",
                ReferenceCode = "45750000001"
            };

            /*
             * TIPS for Reference Code:
             * - Fetch the latest count for payment reference in your database
             * - Store it in a variable or update your table that holds the last reference count
             * - IMPORTANT: Make sure that your reference code is unique. Bad Request will occur if code is repeating
             */
            // If your short code is 21554575, then your reference code prefix is 4575 + 7digit numbers

            var result = api.Charge(payload);

            L("Data: " + result);
        }
Beispiel #3
0
        static void TestSmsReceive(string accessToken)
        {
            GlobeLabs api = new GlobeLabs(accessToken);

            const string json = "{\"inboundSMSMessageList\":{\"inboundSMSMessage\":[{\"dateTime\":\"Fri Nov 22 2013 12:12:13 GMT+0000 (UTC)\",\"destinationAddress\":\"21581234\",\"messageId\":null,\"message\":\"Hello\",\"resourceURL\":null,\"senderAddress\":\"9171234567\"}],\"numberOfMessagesInThisBatch\":1,\"resourceURL\":null,\"totalNumberOfPendingMessages\":null}}";
            var          data = api.GetIncomingMessage(json);

            L("Received SMS Messages: " + data.SmsMessageList.Message.InboundSMSMessage.Count());
            L("\tId: " + data.SmsMessageList.Message.InboundSMSMessage[0].MessageId);
            L("\tMessage: " + data.SmsMessageList.Message.InboundSMSMessage[0].Message);
            L("\tFrom: " + data.SmsMessageList.Message.InboundSMSMessage[0].SenderAddress);
            L("\tDate: " + data.SmsMessageList.Message.InboundSMSMessage[0].DateTime);
        }
Beispiel #4
0
        static int doGlobeCall(string mobileNumber, string accessToken, RTTripUpdates tripUpdate)
        {
            // call globe api
            JToken jsonReturn = GlobeLabs.LocateDevice(mobileNumber, accessToken);

            string processResult = "";

            if (((JProperty)jsonReturn.First).Name == "error")
            {
                processResult = ((JProperty)jsonReturn.First).Value.ToString();
                return(0);
            }
            else if (((JProperty)jsonReturn.First).Name == "terminalLocationList")
            {
                globe_lbs lbs       = JsonConvert.DeserializeObject <globe_lbs>(jsonReturn.ToString());
                double    latitude  = Convert.ToDouble(lbs.terminalLocationList.terminalLocation.currentLocation.latitude);
                double    longitude = Convert.ToDouble(lbs.terminalLocationList.terminalLocation.currentLocation.longitude);

                ShapeHolder sh = DetermineClosestPoint(tripUpdate.trip_id, latitude, longitude);
                //ShapeHolder sh = DetermineClosestPoint(tripUpdate.trip_id, 14.58793, 121.05693);

                if (sh.shape_pt_lat > 0)
                {
                    // save data to rt vehicle position
                    RTVehiclePositions vp = new RTVehiclePositions();

                    vp.route_id     = tripUpdate.route_id;
                    vp.trip_id      = tripUpdate.trip_id;
                    vp.direction_id = tripUpdate.direction_id;
                    vp.start_date   = tripUpdate.start_date;
                    vp.start_time   = tripUpdate.start_time;
                    vp.latitude     = sh.shape_pt_lat;
                    vp.longitude    = sh.shape_pt_lon;
                    vp.timestamp    = (long)Functions.ToEpoch(DateTime.UtcNow);

                    db.RTVehiclePositions.Add(vp);
                    return(1);
                }
            }

            return(0);
        }
Beispiel #5
0
        static void TestSmsService(string accessToken)
        {
            L("SMS Service Testing");
            GlobeLabs api = new GlobeLabs(accessToken);

            var numbers = new List <string>();

            numbers.Add("9171234567");
            // and add more numbers ...
            //numbers.Add("917XXXXXXX");

            var payload = new SmsPayload
            {
                Message = "Testing multiple recipients. Sms Service for Globe.",
                Numbers = numbers
            };

            var data = api.PushSms("SHORT_CODE - ex: 21589999", payload);

            L("Data: " + data);
        }