Internal Server Error 500 by Fetching Data with guzzle

1,284 views
Skip to first unread message

Trawell Mildor

unread,
Mar 9, 2017, 5:56:59 AM3/9/17
to Guzzle - PHP HTTP client and REST client framework

Hello Community

sorry for me bad english

So, i have two Laravel 5.2.* Projects on my Xampp Server

Project One has the following route and controller:

route.php

Route::group(['prefix' => 'api', 'middleware' => 'auth:api'], function() {
    Route::resource('test', 'TestController');
});

TestController.php

public function index()
    {

        return response()->json(
            Product::orderBy('id', 'asc')->get());
    }

so, know when i type in Browser the API URL with API Token (http://server1.dev/api/test?api_token=4NymJsHJmcZfyodSB02oWVp3QR5yiRRC63Jr2bkqgVdNuJKPJhvTs3y8Kjzy), i become my data.

[{"id":1,"id_category":1,"productname":"Volvo","description": OND SO ONE

Know i have in Project two following route and controller

route.php

Route::get('/test', 'ApiController@index');

ApiController.php

public function index()
    {
        $url ="http://server1.dev/api/test?api_token=4NymJsHJmcZfyodSB02oWVp3QR5yiRRC63Jr2bkqgVdNuJKPJhvTs3y8Kjzy";
        $client = new Client();
        $response = $client->get($url);
    }

Know i become a 500 Error when i testing this.



Can anyone help me ?

Many Thanks Trawell

abz

unread,
May 29, 2017, 6:16:21 PM5/29/17
to Guzzle - PHP HTTP client and REST client framework
Try :

$Request = $Client->request("GET", $url);
Reply all
Reply to author
Forward
0 new messages