lundi 3 juillet 2017

Laravel - Seed Guzzle JSON response to Database

I am using Guzzle to access an external API:

$api = new Client([
    'base_uri' => 'http://ift.tt/1xKO7iR',
    'cookies' => true, 
]);
$api->post('ajaxauth/login', [
     'form_params' => [
         'identity' => 'myidentity', 
         'password' => 'mypassword', 
      ],
]);
$response = $api->get('basicspacedata/query/class/boxscore/format/json');
return json_decode($response->getBody()->getContents());
$api->get('ajaxauth/logout');
dd($boxscore);

With this I am able to access the API and display the JSON file on my webpage. Instead of doing this, what I want to do is to seed the JSON result into my database and then display it from my own database.

I am able to seed a local JSON file, but I am unable to seed the Guzzle result.

Is there anyway to seed a Guzzle response JSON file into my database?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire