1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- /**
- * 添加自定义辅助函数
- */
- if ( ! function_exists('config_path'))
- {
- /**
- * Get the configuration path.
- *
- * @param string $path
- * @return string
- */
- function config_path($path = '')
- {
- return app()->basePath() . '/config' . ($path ? '/' . $path : $path);
- }
- }
- if (! function_exists('public_path')) {
- /**
- * Get the path to the public folder.
- *
- * @param string $path
- * @return string
- */
- function public_path($path = '')
- {
- return app()->basePath() . '/public' . ($path ? '/' . $path : $path);
- }
- }
- function http($url, $param, $method = 'post')
- {
- try {
- $client = new \GuzzleHttp\Client();
- $response = $client->request($method, $url, $param);
- \Illuminate\Support\Facades\Log::debug($response);
- $result = json_decode($response->getBody()->getContents(), true);
- \Illuminate\Support\Facades\Log::debug(\GuzzleHttp\json_encode($result));
- if ($result['code'] == 0) {
- \Illuminate\Support\Facades\Log::debug(\GuzzleHttp\json_encode($result['data']));
- return $result['data'];
- } else {
- return [];
- }
- } catch (\Exception $exception) {
- return [];
- }
- }
|