wupengfei 2 年之前
父節點
當前提交
5dcadd546c
共有 3 個文件被更改,包括 45 次插入5 次删除
  1. 4 3
      .idea/workspace.xml
  2. 40 1
      application/api/common.php
  3. 1 1
      application/api/controller/Qc.php

+ 4 - 3
.idea/workspace.xml

@@ -3,6 +3,7 @@
   <component name="ChangeListManager">
     <list default="true" id="1a36929e-c054-4875-a943-593a74e55fa4" name="Default Changelist" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/api/common.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/api/common.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/application/api/controller/Qc.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/api/controller/Qc.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
@@ -215,7 +216,7 @@
       <workItem from="1663807609347" duration="18144000" />
       <workItem from="1663893231881" duration="18711000" />
       <workItem from="1664152288609" duration="21956000" />
-      <workItem from="1664239350913" duration="6064000" />
+      <workItem from="1664239350913" duration="6159000" />
     </task>
     <servers />
   </component>
@@ -241,10 +242,10 @@
       <screen x="0" y="0" width="2560" height="1400" />
     </state>
     <state x="1175" y="519" key="#com.intellij.fileTypes.FileTypeChooser/0.0.2560.1400@0.0.2560.1400" timestamp="1659079177590" />
-    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1664171734445">
+    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1664331585846">
       <screen x="0" y="0" width="2560" height="1400" />
     </state>
-    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/0.0.2560.1400@0.0.2560.1400" timestamp="1664171734445" />
+    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/0.0.2560.1400@0.0.2560.1400" timestamp="1664331585846" />
     <state x="283" y="145" width="1942" height="1088" key="DiffContextDialog" timestamp="1663811165220">
       <screen x="0" y="0" width="2560" height="1400" />
     </state>

+ 40 - 1
application/api/common.php

@@ -1,5 +1,6 @@
 <?php
 // 接口公共方法
+use app\common\model\UserMessage;
 use think\Db;
 use JPush\Client;
 require_once env('root_path').'vendor/jpush/jpush/autoload.php';
@@ -73,8 +74,46 @@ function get_calendar($day = 7,$type='asc'){
    if($type == 'asc') array_multisort(array_column($data,'time_int'),SORT_ASC,$data);
    return $data;
 }
+function jg_push()
+{
+    $user_id = 65 ;
+    $alert ='aaa';
+    if(empty($user_id)) return false;
+    $appKey = '02a7faefd91c8a6a446a6a14';
+    $masterSecret = 'ba2e100db997024d9b6e5d35';
+    $client = new Client($appKey, $masterSecret,null);
+    $push_payload = $client->push()
+        ->setPlatform(array('ios', 'android'))
+        ->addAlias(strval($user_id))
+        ->iosNotification($alert, array(
+            'badge' => '+1',
+            'content-available' => true,
+            'mutable-content' => true,
+            'category' => 'jiguang',
+            'extras' => array(
+                'key' => 'value',
+                'jiguang'
+            ),
+        ))->androidNotification($alert, array(
+            'title' => '消息通知',
+            // 'builder_id' => 2,
+            'extras' => array(
+                'key' => 'value',
+                'jiguang'
+            ),
+        ))->options(array(
+            'apns_production' => True,
+        ));
+    try {
+        $response = $push_payload->send();
+        return $response;
+    } catch  (\JPush\Exceptions\APIConnectionException $e) {
+        return $e;
+    } catch (\JPush\Exceptions\APIRequestException $e) {
+        return $e;
+    }
 
-
+}
 
 
 

+ 1 - 1
application/api/controller/Qc.php

@@ -36,7 +36,7 @@ class Qc extends Base {
 
     public function index()
     {
-        $re = UserMessage::Jpush(65,'aaa');
+        $re = jg_push();
         var_dump($re);
         die();
         $user_id = 65 ;