HyperTrack API Integrate into Laravel- Part 1.

hypertrack

In this tutorial, I will explain how to integrate HyperTrack API in laravel.

Generally, HyperTrack API uses for tracking user location and gives information of like current user location, city, latitude and longitude, device and device OS etc.

Step 1: Install package

So first, you have to install Guzzle Package in your System.

So open your terminal and put the below command.

composer require guzzlehttp/guzzle

After successfully install command let’s move to second step:


Step 2: Create an account in HyperTrack API.

Now open Hypertrack API site and if you had account then login otherwise create account.

If You have Android phone or IOS Operating System the Download HyperTrack Live Tracking System Application and login via credential which you are already using in Web site login or Create.

After login or create account you will get going into Setup and get the two keys:

AccountId: Here your Account Key
SecretKey: Here your Secret Key
Device ID: Here your Device ID

After login you will also get Device id


Step 3: Create a Controller in Laravel

So terminal and put the below command

php artisan make:controller Track/TrackController

Aftre the create a controller put the below code:

<?php

namespace App\Http\Controllers\Track;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Http;

class TrackingController extends Controller{
    public function index(Request $request){
        $client = new \GuzzleHttp\Client();
        $device_id = "Enter Your Device ID";
        $res = $client->request('GET', 
          'https://v3.api.hypertrack.com/devices?$device_id', [
           'auth' => [
              'Enter your Account Key', 
              'Enter your Secret Key'
            ],
        ]);
       echo $res->getStatusCode().'<br>';
       echo $res->getHeader('content-type')[0].'<br>';
       echo $res->getBody();
       return view('track.index'); 
    }

The More information if you want to know then goto HyperTrack API Docs.


Step 4: Create A Route.

Open Your web.php and put the below code:

Route::get('/track','Track\TrackingController@index')->name('track');

Step 5: Create a Blade File

Create folder name is a track and inside track folder create Blade file name is index.blade.php.

Here your final URL:

http://127.0.0.1:8000/track

You will get the data in json format.


Stay Home ! Stay Safe

About Dhaval Shah

My name is Dhaval Shah. I'm a PHP developer, entrepreneur and CEO of DAG inventions PVT ltd. I live in India and I love to write tutorials and tips that can help other developers. I am a big fan of PHP, Java-script, JQuery, Laravel, WordPress and Bootstrap.
Follow me on Github / Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!