12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace common\logic;
- use components\Curl;
- use components\Exception;
- /**
- * 登陆
- * Class LoginHandle
- * @package common\logic
- */
- class LoginHandle
- {
- const URL = 'https://zpapi.licai.cn';
- /**
- * login
- * @author: libingke
- * @param $body
- * @return array
- */
- public function login($body)
- {
- $post = json_decode($body, true);
- if (!is_array($post))
- throw new Exception(1304, '消息格式错误');
- $post['redirect_uri'] = 'https://zpapi.licai.cn';
- $curl = new Curl();
- $curl->setPostParams($post);
- $result = json_decode($curl->post(static::URL), true);
- if ($curl->responseCode != 200)
- throw new Exception($curl->responseCode);
- if ($curl->errorText)
- throw new Exception(1304, $curl->errorText);
- if (isset($result['error']) && is_string($result['error']))
- throw new Exception(1304, $result['error']);
- $json = json_encode($result);
- return $json;
- }
- }
|