备份提交
This commit is contained in:
parent
39c0465ee3
commit
0fa3305acd
@ -35,26 +35,37 @@ class ControllerBase extends Phalcon\Mvc\Controller{
|
||||
curl_close($curl);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* curl post
|
||||
*/
|
||||
function __http_post_request($url, $postArr){
|
||||
function __http_post_request($url, $data=null, $is_json=false){
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
//curl_setopt ( $curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
|
||||
curl_setopt($curl, CURLOPT_SSLVERSION, 1);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 15);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 0);
|
||||
curl_setopt($curl, CURLOPT_POST, 1);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postArr);
|
||||
if(!empty($data)){
|
||||
if($is_json && is_array($data)){
|
||||
$data = json_encode($data);
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_POST, 1);
|
||||
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);
|
||||
$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);
|
||||
return $data;
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -11,12 +11,25 @@ class Oauth2Controller extends ControllerBase{
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取code(Get code)
|
||||
* http://127.0.0.1/tiffany/api/oauth2/code?qaz=wsx
|
||||
*/
|
||||
function codeAction(){
|
||||
|
||||
echo "111"; die;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
12
app/models/Smsapioauth2Accesstoken.php
Normal file
12
app/models/Smsapioauth2Accesstoken.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* AccessToken表
|
||||
* @author QZQ
|
||||
*/
|
||||
class Smsapioauth2Accesstoken extends AppModel{
|
||||
|
||||
public function initialize(){
|
||||
$this->setSource("smsapioauth2_accesstoken");
|
||||
}
|
||||
|
||||
}
|
||||
12
app/models/Smsapioauth2Appinfo.php
Normal file
12
app/models/Smsapioauth2Appinfo.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* AccessToken表
|
||||
* @author QZQ
|
||||
*/
|
||||
class Smsapioauth2Appinfo extends AppModel{
|
||||
|
||||
public function initialize(){
|
||||
$this->setSource("smsapioauth2_appinfo");
|
||||
}
|
||||
|
||||
}
|
||||
12
app/models/Smsapioauth2Refreshtoken.php
Normal file
12
app/models/Smsapioauth2Refreshtoken.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* AccessToken表
|
||||
* @author QZQ
|
||||
*/
|
||||
class Smsapioauth2Refreshtoken extends AppModel{
|
||||
|
||||
public function initialize(){
|
||||
$this->setSource("smsapioauth2_refreshtoken");
|
||||
}
|
||||
|
||||
}
|
||||
12
app/models/Smsapioauth2Tempcode.php
Normal file
12
app/models/Smsapioauth2Tempcode.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* AccessToken表
|
||||
* @author QZQ
|
||||
*/
|
||||
class Smsapioauth2Tempcode extends AppModel{
|
||||
|
||||
public function initialize(){
|
||||
$this->setSource("smsapioauth2_tempcode");
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user