示例#1
0
文件: Crew.php 项目: ratibus/pflow
 /**
  * @throws RuntimeException
  * @param $projectId
  * @param $branch
  * @return array
  */
 public function reviewStatus($projectId, $branch)
 {
     $client = new Http_Client();
     $response = $client->get(sprintf('%s/api.php/projects/%s/reviews/%s', $this->getUrl(), $projectId, $branch));
     $json = (array) json_decode($response->getContent());
     if ($response->getCode() != 200 || $json === null || count($json) == 0) {
         if (isset($json['message'])) {
             throw new RuntimeException(sprintf('Crew->reviewStatus : %s', $json['message']));
         }
         throw new RuntimeException(sprintf("Crew->reviewStatus : invalid result data.\n\n%s", $response->getContent()));
     }
     return $json;
 }
示例#2
0
 /**
  * @param string $job_url
  * @param array $parameters
  *
  * @throws Tracker_Exception
  */
 public function launchJobBuild($job_url, array $build_parameters = array())
 {
     $options = array(CURLOPT_URL => $this->getBuildUrl($job_url), CURLOPT_SSL_VERIFYPEER => false, CURLOPT_POST => true);
     if (count($build_parameters) > 0) {
         $options[CURLOPT_POSTFIELDS] = $this->generateBuildParameters($build_parameters);
     }
     $this->http_curl_client->addOptions($options);
     try {
         $this->http_curl_client->doRequest();
     } catch (Http_ClientException $e) {
         throw new Jenkins_ClientUnableToLaunchBuildException('Job: ' . $job_url . '; Message: ' . $e->getMessage());
     }
 }
示例#3
0
 public function itTimeoutsInFiveSeconds()
 {
     $client = new Http_Client();
     $this->assertEqual($client->getOption(CURLOPT_TIMEOUT), 5);
 }
 function http_socket($url, $method, $postfields = NULL, $multi = false)
 {
     jext('http_client');
     $http = new Http_Client($this->debug);
     $http->setHeader('user-agent', $this->useragent);
     if ($this->access_token) {
         $http->setHeader('authorization', 'OAuth2 ' . $this->access_token);
     }
     $http->setHeader('API-RemoteIP', $GLOBALS['_J']['client_ip']);
     if ('POST' == $method) {
         if ($postfields && is_array($postfields)) {
             if ($multi && isset($postfields['pic'])) {
                 if (is_array($postfields['pic'])) {
                     $http->addPostFile('pic', $postfields['pic']['name'], $postfields['pic']['data']);
                 } else {
                     $http->addPostFile('pic', $postfields['pic']);
                 }
                 unset($postfields['pic']);
             }
             foreach ($postfields as $k => $v) {
                 $http->addPostField($k, $v);
             }
         }
         return $http->Post($url, false);
     } else {
         if ($postfields) {
             $url = $this->_get_url($url, $postfields);
         }
         return $http->Get($url, false);
     }
 }
示例#5
0
文件: pay.php 项目: yiuked/tmcart
 if (function_exists('fsockopen')) {
     $type = 'fsockopen';
     $parts = parse_url(handler);
     $host = $parts['host'];
     $scheme = isset($parts['scheme']) ? strtolower($parts['scheme']) : '';
     $path = isset($parts['path']) ? $parts['path'] : '/';
     if (isset($parts['port'])) {
         $port = intval($parts['port']);
     } else {
         if ($scheme == 'https') {
             $port = 443;
         } else {
             $port = 80;
         }
     }
     $httpClient = new Http_Client($host);
     $httpClient->setDebug(PAY_DEBUG);
     $httpClient->setPersistReferers(false);
     $httpClient->referer = $referer;
     $httpClient->setUserAgent($userAgent);
     $httpClient->timeout = HTTP_TIMEOUT;
     $flag = $httpClient->post($path, $data);
     $status = $httpClient->getStatus();
     if ($flag === true) {
         $result = $httpClient->getContent();
     } else {
         $error = $httpClient->getError();
     }
 } else {
     Paylog::msg($cart->id, "300", "尝试curl和fsockopen提交定单到速汇通,均失败!");
     die(json_encode(array("isError" => "YES", "msg" => "300")));