This commit is contained in:
候学杰 2018-03-15 19:44:34 +08:00
parent e693f75563
commit 57335f98ce
2 changed files with 6 additions and 6 deletions

View File

@ -33,14 +33,14 @@ class Client
*/ */
public function call($uri, $params) public function call($uri, $params)
{ {
$config = array_merge(['timeout' => 1], $config = array_merge(['timeout' => 3],
$this->config[$this->currentApp]); $this->config[$this->currentApp]);
$secret = $config['secret'];
unset($config['secret']); unset($config['secret']);
$client = new \GuzzleHttp\Client($config); $client = new \GuzzleHttp\Client($config);
$params['appid'] = $config['appid']; $params['appid'] = $config['appid'];
$params['timestamp'] = time(); $params['timestamp'] = time();
$key = $this->config[$this->currentApp]['secret']; $params['sign'] = sign($params, $secret);
$params['sign'] = sign($params, $key);
$resp = $client->post($uri, ['form_params' => $params]); $resp = $client->post($uri, ['form_params' => $params]);
if ($resp->getStatusCode() == 200) { if ($resp->getStatusCode() == 200) {
return \GuzzleHttp\json_decode($resp->getBody(), true); return \GuzzleHttp\json_decode($resp->getBody(), true);

View File

@ -18,9 +18,9 @@ class InternalApiServiceProvider extends ServiceProvider
$this->app->singleton('internal.api', function () { $this->app->singleton('internal.api', function () {
return new Client(config('internal_api.client')); return new Client(config('internal_api.client'));
}); });
foreach (config('internal_api.client') as $appid => $config) { foreach (config('internal_api.client') as $key => $config) {
$this->app->singleton('internal.api.' . $appid, function () use ($appid) { $this->app->singleton('internal.api.' . $key, function () use ($key) {
return $this->app['internal.api']->app($appid); return $this->app['internal.api']->app($key);
}); });
} }