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)
{
$config = array_merge(['timeout' => 1],
$config = array_merge(['timeout' => 3],
$this->config[$this->currentApp]);
$secret = $config['secret'];
unset($config['secret']);
$client = new \GuzzleHttp\Client($config);
$params['appid'] = $config['appid'];
$params['timestamp'] = time();
$key = $this->config[$this->currentApp]['secret'];
$params['sign'] = sign($params, $key);
$params['sign'] = sign($params, $secret);
$resp = $client->post($uri, ['form_params' => $params]);
if ($resp->getStatusCode() == 200) {
return \GuzzleHttp\json_decode($resp->getBody(), true);

View File

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