-
-
Save williamvilasboas/c1a0f31fd0dc8372eeac892cae8a1494 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers\OmieCustomers; | |
use Illuminate\Http\Request; | |
use App\Http\Controllers\Controller; | |
use GuzzleHttp\Client; | |
use GuzzleHttp\Exception\RequestException; | |
class OmieCustomersController extends Controller | |
{ | |
public function index() | |
{ | |
$data = [ | |
"call" => "ListarClientes", | |
"app_key" => "1560731700", | |
"app_secret" => "226dcf372489bb45ceede61bfd98f0f1", | |
"param" => [ | |
"pagina" => 1, | |
"registros_por_pagina" => 100, | |
"apenas_importado_api" => "N" | |
] | |
]; | |
$data_string = json_encode($data); | |
$ch = curl_init('http://app.omie.com.br/api/v1/geral/clientes/'); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
'Content-Type: application/json', | |
'Content-Length: ' . strlen($data_string)) | |
); | |
$result = curl_exec($ch); | |
print_r($result); | |
} | |
} | |
/* | |
try { | |
$client = new Client([ | |
'base_uri' => 'http://app.omie.com.br', | |
'timeout' => 2.0, | |
]); | |
$response = $client->request( | |
'POST', | |
'/api/v1/geral/clientes/', | |
[ | |
'body' => json_encode([ | |
'call' => 'ListarClientes', | |
'app_key' => '1560731700', | |
'app_secret' => '226dcf372489bb45ceede61bfd98f0f1', | |
'param' => [ | |
'pagina' => 1, | |
'registros_por_pagina' => 100, | |
'apenas_importado_api' => 'S' | |
] | |
]) | |
] | |
); | |
//return json_decode($response->getBody()->getContents()); | |
print_r($response->getBody()->getContents()); | |
} catch (RequestException $e) { | |
return $e; | |
} | |
*/ |
Author
williamvilasboas
commented
May 22, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment