瀏覽代碼

header接收lang

lizhen_gitee 1 年之前
父節點
當前提交
b39fc228cb

+ 25 - 34
application/api/controller/Demo.php

@@ -3,7 +3,8 @@
 namespace app\api\controller;
 
 use app\common\controller\Api;
-
+use Aws\Sns\SnsClient;
+use Aws\Exception\AwsException;
 /**
  * 示例接口
  */
@@ -38,6 +39,29 @@ class Demo extends Api
          'msg':'返回成功'
         })
      */
+
+    public function test1(){
+        $SnSclient = new SnsClient([
+            'profile' => 'default',
+            'region' => 'us-east-1',
+            'version' => '2010-03-31'
+        ]);
+
+        $subscription_token = 'arn:aws:sns:us-east-1:111122223333:MyTopic:123456-abcd-12ab-1234-12ba3dc1234a';
+        $topic = 'arn:aws:sns:us-east-1:111122223333:MyTopic';
+
+        try {
+            $result = $SnSclient->confirmSubscription([
+                'Token' => $subscription_token,
+                'TopicArn' => $topic,
+            ]);
+            var_dump($result);
+        } catch (AwsException $e) {
+            // output error message if fails
+            error_log($e->getMessage());
+        }
+    }
+
     public function test(){
         $out_trade_no = createUniqueNo('Test');
         $money = '1';
@@ -98,37 +122,4 @@ class Demo extends Api
 
 
 
-    /**
-     * 需要登录的接口
-     *
-     */
-    public function test2()
-    {
-        $url = 'https://api.hit-pay.com/v1/payment-requests';
-        $data = [
-            'amount' => 1,
-            //'payment_method' => ['paynow_online', 'card', 'wechat', 'alipay', 'grabpay', 'fave_duit', 'shopback', 'atome'],
-            'currency' => 'SGD',
-            //'webhook' => '',
-        ];
-
-        $header = array(
-            'X-BUSINESS-API-KEY' => '096a06e94fb1e0a8b015485bb76ef5dd63c167679297e07331a687327bd8b12e',
-            'Content-Type' => 'application/x-www-form-urlencoded',
-            'X-Requested-With' => 'XMLHttpRequest'
-        );
-
-        $rs = curl_post($url,$data,$header);
-        dump($rs);
-    }
-
-    /**
-     * 需要登录且需要验证有相应组的权限
-     *
-     */
-    public function test3()
-    {
-        $this->success('返回成功', ['action' => 'test3']);
-    }
-
 }

+ 2 - 2
application/api/controller/coach/Lesson.php

@@ -2,12 +2,12 @@
 
 namespace app\api\controller\coach;
 
-use app\common\controller\Api;
+use app\common\controller\Apic;
 use think\Db;
 /**
  * 售课
  */
-class Lesson extends Api
+class Lesson extends Apic
 {
     // 无需登录的接口,*表示全部
     protected $noNeedLogin = [];

+ 1 - 1
application/common/controller/Api.php

@@ -81,7 +81,7 @@ class Api
     public function __construct(Request $request = null)
     {
         $this->request = is_null($request) ? Request::instance() : $request;
-        $this->lang = input('lang','CN');
+        $this->lang = $this->request->header('lang','CN');
 
         // 控制器初始化
         $this->_initialize();

+ 2 - 1
application/common/controller/Apic.php

@@ -64,7 +64,7 @@ class Apic
      */
     protected $responseType = 'json';
 
-
+    protected $lang = 'CN';
     /**
      * 构造方法
      * @access public
@@ -73,6 +73,7 @@ class Apic
     public function __construct(Request $request = null)
     {
         $this->request = is_null($request) ? Request::instance() : $request;
+        $this->lang = $this->request->header('lang','CN');
 
 
         // 控制器初始化