作者 何书鹏

测试

@@ -8,6 +8,7 @@ use app\api\model\UserCoupon; @@ -8,6 +8,7 @@ use app\api\model\UserCoupon;
8 use app\common\controller\Api; 8 use app\common\controller\Api;
9 use EasyWeChat\Factory; 9 use EasyWeChat\Factory;
10 use fast\Http; 10 use fast\Http;
  11 +use GuzzleHttp\Client;
11 use think\Config; 12 use think\Config;
12 use think\Db; 13 use think\Db;
13 use think\Validate; 14 use think\Validate;
@@ -820,21 +821,14 @@ class User extends Api @@ -820,21 +821,14 @@ class User extends Api
820 * 测试 821 * 测试
821 */ 822 */
822 public function ceshi(){ 823 public function ceshi(){
823 - $push_api_url = request()->domain().":2121/";  
824 - $post_data = array(  
825 - 'type' => 'publish',  
826 - 'content' => '这个是推送的测试数据',  
827 - 'to' => '',  
828 - );  
829 - $ch = curl_init ();  
830 - curl_setopt ( $ch, CURLOPT_URL, $push_api_url );  
831 - curl_setopt ( $ch, CURLOPT_POST, 1 );  
832 - curl_setopt ( $ch, CURLOPT_HEADER, 0 );  
833 - curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );  
834 - curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post_data );  
835 - curl_setopt ( $ch, CURLOPT_HTTPHEADER, array("Expect:"));  
836 - $return = curl_exec ( $ch );  
837 - curl_close ( $ch );  
838 - halt($return); 824 + $client = new Client();
  825 + $response = $client->request('POST', request()->domain().":2121/", [
  826 + 'form_params' => [
  827 + 'type' => 'publish',
  828 + 'content' => '这个是推送的测试数据',
  829 + 'to' => '',
  830 + ]
  831 + ]);
  832 + halt($response->getBody()->getContents());
839 } 833 }
840 } 834 }