Example #1
0
 private function _send($url, $params = array())
 {
     $updatesrv = Yii::$app->params['updatesrv'];
     $curl = new \app\helpers\Curl();
     $output = $curl->setOptions(array('Content-Type: application/xml', CURLOPT_CAINFO => Yii::$app->basePath . '/data/rootCA.pem', CURLOPT_USERAGENT => $this->_sversion))->post($updatesrv . $url, \yii\helpers\Json::encode($params));
     $response = \yii\helpers\Json::decode($output);
     if (!isset($response["status"])) {
         throw new \Exception($output);
     }
     if ($response["status"] != 200) {
         throw new \Exception($response["status"] . "-" . $response["body"]);
     }
     return $response["body"];
 }
Example #2
0
 public function send()
 {
     $params = array('title' => $this->title, 'body' => $this->body);
     $url = $this->site . "/" . $this->owner . "/" . $this->project . "/issues";
     var_dump($url);
     var_dump(json_encode($params));
     $curl = new \app\helpers\Curl();
     $output = $curl->setOptions([CURLOPT_POST => true, CURLOPT_USERAGENT => 'Linet3.1', CURLOPT_USERPWD => $this->authUser . ":" . $this->authPasswd, CURLOPT_RETURNTRANSFER => true])->post($url, json_encode($params));
     var_dump($output);
     $output = strstr($output, "\r\n\r\n");
     $output = str_replace("\r\n\r\n", "", $output);
     $output = json_decode($output);
     //print_r($output->html_url);
     if (isset($output->html_url)) {
         $this->url = $output->html_url;
         $this->save();
         return $this->url;
     } else {
         return false;
     }
     //return ;
 }