/**
  * Lists all Country models.
  * @return mixed
  */
 public function actionSave()
 {
     $url = 'http://api.ec.com/ec/save?tokenid=49whfwmzh4&appkey=hlt2014api&clientid=YXA63VpnwIszEeSjZqcGJBng8Q';
     $data = ['name' => 'wjh', 'age' => 19];
     $result = NetHelper::curl_post($url, $data, 'string');
     $result = json_decode($result);
     if ($result && $result->status && $result->status == 'successful') {
         var_dump($result->data);
         //Yii::$app->session->set('token',$result->data);
         //Yii::$app->session->set($result->data->tokenid,$result->data);
     } else {
         var_dump('操作失败,原因 :' . $result->message);
     }
     /*echo $result;*/
 }
예제 #2
0
 public static function sendSMSCommon($phone, $auth_id, $template_id, $params = array(), $ext = '', $sleep_time = 0)
 {
     if (Yii::$app->getRequest() instanceof \yii\web\Request) {
         Yii::info('sms common interface: ' . $auth_id . ' ' . $template_id . ' ' . Yii::$app->getRequest()->getUrl(), 'sms');
     } else {
         Yii::info('sms common interface: ' . $auth_id . ' ' . $template_id, 'sms');
     }
     $apikeys = Yii::$app->params[self::SERVICE_INTERFACE]['apikeys'];
     $url = Yii::$app->params[self::SERVICE_INTERFACE]['url'];
     $auth_id = strval($auth_id);
     if (!isset($apikeys[$auth_id])) {
         Yii::error("短信发送错误: " . $auth_id . " not exists! (" . $phone . ")", 'sms');
         return false;
     }
     $post_data = ['apikey' => $apikeys[$auth_id], 'auth_id' => $auth_id, 'template_id' => strval($template_id), 'mobile' => $phone, 'params' => json_encode($params), 'ext' => $ext];
     if (intval($sleep_time) > 0) {
         $post_data['sleep_time'] = intval($sleep_time);
     }
     $query = http_build_query($post_data);
     $response = NetHelper::cURLHTTPPost($url, $query);
     if ($response == false) {
         Yii::error("短信发送连接失败: mobile:{$phone} auth_id:{$auth_id} template_id:{$template_id}", 'sms');
         return false;
     } else {
         $resp = json_decode(trim($response, chr(239) . chr(187) . chr(191)), true);
         if ($resp['errno'] != 0) {
             Yii::error("短信发送失败: mobile:{$phone} auth_id:{$auth_id} template_id:{$template_id} error_msg:{$resp['errmsg']}", 'sms');
             return false;
         } else {
             Yii::info("短信发送成功: mobile:{$phone} auth_id:{$auth_id} template_id:{$template_id}", 'sms');
             return true;
         }
     }
 }
예제 #3
0
 /**
  * Deletes an existing Country model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param string $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $url = self::NEWS_URL . '/delete/' . $id;
     $data = [];
     $result = NetHelper::curl_post($url, $data, 'string', 0, null, 'DELETE');
     echo $result;
 }