samedi 13 juillet 2019

Not sure what is this in "GoogleController" file_get_contents

Hello guys i'm new on laravel and i have this error i don't really know what is this at all so i hope someone could help me and solve it!

E/errror: {
    "message": "file_get_contents(https://maps.googleapis.com/maps/api/directions/json?origin=**.89**9029,**.8584**5&destination=**.897**1522708,**.858512**80171&mode=driving&key=**********): failed to open stream: Connection timed out",
    "exception": "ErrorException",
    "file": "/home/**/domains/**.tech/app/Http/Controllers/Helper/GoogleController.php",
    "line": 99,
    "trace": [
        {
            "function": "handleError",
            "class": "Illuminate\\Foundation\\Bootstrap\\HandleExceptions",
            "type": "->"
        },
        {
            "file": "/home/**/domains/**.tech/app/Http/Controllers/Helper/GoogleController.php",
            "line": 99,
            "function": "file_get_contents"
        },
        {
            "file": "/home/**/domains/**.tech/app/Http/Controllers/Api/BookingController.php",
            "line": 1854,
            "function": "GoogleDistanceAndTime",
            "class": "App\\Http\\Controllers\\Helper\\GoogleController",
            "type": "::"
        },
        {
            "file": "/home/**/domains/**.tech/app/Http/Controllers/Api/BookingController.php",
            "line": 1831,
            "function": "EtaCalculation",
            "class": "App\\Http\\Controllers\\Api\\BookingController",
            "type": "->"
        },
        {
            "function": "Tracking",
            "class": "App\\Http\\Controllers\\Api\\BookingController",
            "type": "->"
        },
        {
            "file": "/home/**/domains/**.tech/vendor/laravel/framework/src/Illuminate/Routing/Controller.php",
            "line": 54,
            "function": "call_user_func_array"
        },
        {
            "file": "/home/**/domains/**.tech/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
            "line": 45,
            "function": "callAction",
            "class": "Illuminate\\Routing\\Controller",
            "type": "->"
        },
        {
            "file": "/home/**/domains/**.tech/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
            "line": 219,
            "function": "dispatch",
            "class": "Illuminate\\Routing\\ControllerDispatcher",
            "type": "->"
        },
        {
            "file": "/home/**/domains/**.tech/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
            "line": 176,
            "function": "runController",
            "class": "Illuminate\\Routing\\Route",
            "type": "->"
        },
        {
            "file": "/home/**/domains/**.tech/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 680,
            "function": "run",
            "class": "Illuminate\\Routing\\Route",
            "type": "->"
        },
        {
            "file": "/home/**/domains/**.tech/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line": 30,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/home/**/domains/**.tech/app/Http/Middleware/ValidUser.php",
            "line": 25,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "/home/**/domains/**.tech/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 163,
            "function": "handle",
            "class": "App\\Http\\Middleware\\ValidUser",
            "type": "->"
        },
        {
            "file": "/home/**/domains/**.tech/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type
responseFromServerError

And this the function inside laravel App / Http / Controllers /Helper / GoogleController.php I'm really lost don't know what happened

public static function GoogleDistanceAndTime($from, $to, $key)
{
    $data = file_get_contents("https://maps.googleapis.com/maps/api/directions/json?origin=$from&destination=$to&mode=driving&key=$key");
    $data = json_decode($data, true);
    $status = $data['status'];
    if ($status != "OK") {
        return array('time' => "", 'distance' => "");
    } else {
        $time = $data['routes'][0]['legs'][0]['duration']['text'];
        $distance = $data['routes'][0]['legs'][0]['distance']['text'];
        return array('time' => $time, 'distance' => $distance);
    }
}

ask me to show anything if you need Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire