备份提交

This commit is contained in:
qinzongqing 2023-04-10 12:49:07 +08:00
parent 39c0465ee3
commit 0fa3305acd
6 changed files with 84 additions and 12 deletions

View File

@ -39,22 +39,33 @@ class ControllerBase extends Phalcon\Mvc\Controller{
/** /**
* curl post * curl post
*/ */
function __http_post_request($url, $postArr){ function __http_post_request($url, $data=null, $is_json=false){
$curl = curl_init(); $curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
//curl_setopt ( $curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); if(!empty($data)){
curl_setopt($curl, CURLOPT_SSLVERSION, 1); if($is_json && is_array($data)){
curl_setopt($curl, CURLOPT_TIMEOUT, 60); $data = json_encode($data);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 15); }
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postArr); curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
//发送JSON数据
if($is_json){
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8', 'Content-Length:'.strlen($data)));
}
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl); $res = curl_exec($curl);
$errorno = curl_errno($curl);
if($errorno){
$error = array();
$error = array('errorno'=>false, 'errmsg'=>$errorno, 'msg'=>curl_error($curl), 'info'=>curl_getinfo($curl));
return $error;
}
curl_close($curl); curl_close($curl);
return $data; return $res;
} }
/** /**

View File

@ -11,12 +11,25 @@ class Oauth2Controller extends ControllerBase{
parent::initialize(); parent::initialize();
} }
/**
* 测试方法
* http://127.0.0.1/tiffany/api/oauth2/test?qaz=wsx
*/
function testAction(){
$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/oauth2/code";
$post_arr = array();
$post_arr['appid'] = "0e355010-67b9-4aa6-a53f-c92c972094a7";
$post_json = json_encode($post_arr);
$result = $this->__http_post_request($url, $post_json, true);
print_r($result); die;
}
/** /**
* 获取codeGet code * 获取codeGet code
* http://127.0.0.1/tiffany/api/oauth2/code?qaz=wsx * http://127.0.0.1/tiffany/api/oauth2/code?qaz=wsx
*/ */
function codeAction(){ function codeAction(){
echo "111"; die;
} }
/** /**

View File

@ -0,0 +1,12 @@
<?php
/**
* AccessToken表
* @author QZQ
*/
class Smsapioauth2Accesstoken extends AppModel{
public function initialize(){
$this->setSource("smsapioauth2_accesstoken");
}
}

View File

@ -0,0 +1,12 @@
<?php
/**
* AccessToken表
* @author QZQ
*/
class Smsapioauth2Appinfo extends AppModel{
public function initialize(){
$this->setSource("smsapioauth2_appinfo");
}
}

View File

@ -0,0 +1,12 @@
<?php
/**
* AccessToken表
* @author QZQ
*/
class Smsapioauth2Refreshtoken extends AppModel{
public function initialize(){
$this->setSource("smsapioauth2_refreshtoken");
}
}

View File

@ -0,0 +1,12 @@
<?php
/**
* AccessToken表
* @author QZQ
*/
class Smsapioauth2Tempcode extends AppModel{
public function initialize(){
$this->setSource("smsapioauth2_tempcode");
}
}