| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 | 
							- <?php
 
- // 智慧灯杆wifi设备收发指令脚本
 
- require_once __DIR__ . '/Autoloader.php';
 
- use Workerman\Worker;
 
- use Workerman\Connection\TcpConnection;
 
- use \Workerman\Lib\Timer;
 
- require_once './Lib/mysql/src/Connection.php';
 
- $tcp_worker = new Worker("tcp://0.0.0.0:8090");
 
- $tcp_worker->onWorkerStart = function($ws_worker)
 
- {
 
-     global $cmdClientList;
 
-     $cmdClientList = [];
 
-     $url = 'https://device.api.ct10649.com:8743/iocm/app/sec/v1.1.0/login';
 
-     $data = array(
 
-         'appId' => 'L_JzQ9KoR0py5X6fEGjO9p2PsWYa',
 
-         'secret' => 'pO9P7mecnU2KeucxkxuxiWbGBDsa',
 
-     );
 
-     $jsonData = json_encode($data);
 
-     var_dump(curl($url,$data));
 
-     // 指令返回结果处理
 
-     // Timer::add(1, function()use($ws_worker){
 
-     //     global $globalData;
 
-     //     global $cmdClientList;
 
-     //     do
 
-     //     {
 
-     //         $old_value = $globalData->resList;
 
-     //         $new_value = [];
 
-     //     }
 
-     //     while(!$globalData->cas('resList', $old_value, $new_value));
 
-     //     $resList = $old_value;
 
-     //     if (!empty($resList)) {
 
-     //         foreach ($resList as $resData) {
 
-     //             $resData = json_decode($resData,true);
 
-     //             if (isset($cmdClientList[$resData['devId']])) {
 
-     //                 $cmdClientList[$resData['devId']]->send(json_encode($resData));
 
-     //                 unset($cmdClientList[$resData['devId']]);
 
-     //             }
 
-     //         }
 
-     //     }
 
-     // });
 
- };
 
- // 下发指令
 
- $tcp_worker->onMessage = function($connection, $data)
 
- {
 
-     // global $globalData;
 
-     // global $cmdClientList;
 
-     // $res = json_decode($data,true);
 
-     // if (isset($res['devId'])) {
 
-     //     $cmdClientList[$res['devId']] = $connection;
 
-     //     add_cmd($res);
 
-     // }else{
 
-     // }  
 
- };
 
- function curl($url, $params = false, $ispost = 0, $https = 0)
 
-     {
 
-         $httpInfo = array();
 
-         $ch = curl_init();
 
-         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
 
-         curl_setopt($ch, CURLOPT_TIMEOUT, 30);
 
-         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
-         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
 
-         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
 
-         // curl_setopt($ch, CURLOPT_CAINFO,  'C:\Users\wzh\Desktop\cert\client.crt');
 
-         curl_setopt($ch, CURLOPT_SSLCERT, './cert/outgoing.CertwithKey.pem');
 
-         curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'IoM@1234');
 
-         curl_setopt($ch, CURLOPT_POST, true);
 
-         curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
 
-         curl_setopt($ch, CURLOPT_URL, $url);
 
-         $response = curl_exec($ch);
 
-         if ($response === FALSE) {
 
-             echo "cURL Error: " . curl_error($ch);
 
-             return false;
 
-         }
 
-         $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
-         $httpInfo = array_merge($httpInfo, curl_getinfo($ch));
 
-         curl_close($ch);
 
-         return $response;
 
-     }
 
- Worker::runAll();
 
 
  |