当前位置: 首页>>代码示例>>PHP>>正文


PHP curl_multi_strerror函数代码示例

本文整理汇总了PHP中curl_multi_strerror函数的典型用法代码示例。如果您正苦于以下问题:PHP curl_multi_strerror函数的具体用法?PHP curl_multi_strerror怎么用?PHP curl_multi_strerror使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了curl_multi_strerror函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: exec

 /**
  * Execute multi curl of this Streamer
  *
  * @return boolean
  * @throws Exception
  */
 public function exec()
 {
     if (!$this->isResource()) {
         throw new Exception("Is not a valid cURL Multi Handle resource", Exception::INVALID_MULTI_CURL);
     }
     if (empty($this->streams)) {
         throw new Exception("Pull of streams is empty", Exception::PULL_IS_EMPTY);
     }
     $running = $messages = 0;
     do {
         // executing...
         if (($error = curl_multi_exec($this->curl, $running)) != 0) {
             throw new Exception(curl_multi_strerror($error), Exception::MULTI_CURL_ERROR);
         }
         // we have some completed streams in this iteration
         do {
             if ($read = curl_multi_info_read($this->curl, $messages)) {
                 $handle = $read['handle'];
                 /** @var $stream Stream */
                 $stream = $this->streams[(int) $handle];
                 $stream->setResponse($read['result'], curl_multi_getcontent($handle));
             }
         } while ($messages);
         // in god we trust...
         usleep(1000);
     } while ($running);
     // close descriptors
     $this->closeResource();
     return $this;
 }
开发者ID:pulyavin,项目名称:streams,代码行数:36,代码来源:Streamer.php

示例2: get

 public function get($url_mixed, $data = array())
 {
     if (is_array($url_mixed)) {
         $curl_multi = curl_multi_init();
         $this->_multi_parent = true;
         $this->curls = array();
         foreach ($url_mixed as $url) {
             $curl = new Curl();
             $curl->_multi_child = true;
             $curl->setOpt(CURLOPT_URL, $this->_buildURL($url, $data), $curl->curl);
             $curl->setOpt(CURLOPT_HTTPGET, true);
             $this->_call($this->_before_send, $curl);
             $this->curls[] = $curl;
             $curlm_error_code = curl_multi_add_handle($curl_multi, $curl->curl);
             if (!($curlm_error_code === CURLM_OK)) {
                 throw new \ErrorException('cURL multi add handle error: ' . curl_multi_strerror($curlm_error_code));
             }
         }
         foreach ($this->curls as $ch) {
             foreach ($this->_options as $key => $value) {
                 $ch->setOpt($key, $value);
             }
         }
         do {
             $status = curl_multi_exec($curl_multi, $active);
         } while ($status === CURLM_CALL_MULTI_PERFORM || $active);
         foreach ($this->curls as $ch) {
             $this->exec($ch);
         }
     } else {
         $this->setopt(CURLOPT_URL, $this->_buildURL($url_mixed, $data));
         $this->setopt(CURLOPT_HTTPGET, true);
         return $this->exec();
     }
 }
开发者ID:pawaanv,项目名称:metasploit-pro-trial-grabber,代码行数:35,代码来源:php-curl-class.php

示例3: execute

 public function execute()
 {
     $mh = curl_multi_init();
     $chs = $this->chs();
     $stillRunning = 0;
     $result = array();
     if (function_exists('curl_multi_setopt')) {
         curl_multi_setopt($mh, CURLMOPT_PIPELINING, 1);
         curl_multi_setopt($mh, CURLMOPT_MAXCONNECTS, $this->maxConnectsSize());
     }
     foreach ($chs as $ch) {
         curl_multi_add_handle($mh, $ch);
     }
     do {
         $execReturnValue = curl_multi_exec($mh, $stillRunning);
         curl_multi_select($mh);
     } while ($stillRunning > 0);
     foreach ($chs as $i => $ch) {
         $curlError = curl_error($ch);
         if ($curlError === "") {
             $result[$i] = curl_multi_getcontent($ch);
         } else {
             throw new PubnubException("Curl error on handle {$i}: {$curlError}\n");
         }
         curl_multi_remove_handle($mh, $ch);
         curl_close($ch);
     }
     curl_multi_close($mh);
     $this->requests = array();
     if ($execReturnValue != CURLM_OK) {
         throw new PubnubException(curl_multi_strerror($execReturnValue));
     }
     return $result;
 }
开发者ID:njokipal,项目名称:php,代码行数:34,代码来源:PipelinedClient.php

示例4: get

 public function get($url_mixed, $data = array())
 {
     if (is_array($url_mixed)) {
         $curl_multi = curl_multi_init();
         $this->multi_parent = true;
         $this->curls = array();
         foreach ($url_mixed as $url) {
             $curl = new Curl();
             $curl->multi_child = true;
             $curl->beforeSend($this->before_send_function);
             $curl->success($this->success_function);
             $curl->error($this->error_function);
             $curl->complete($this->complete_function);
             $curl->base_url = $url;
             $curl->url = $this->buildURL($url, $data);
             $curl->setOpt(CURLOPT_URL, $curl->url, $curl->curl);
             $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'GET');
             $curl->setOpt(CURLOPT_HTTPGET, true);
             $this->curls[] = $curl;
             $curlm_error_code = curl_multi_add_handle($curl_multi, $curl->curl);
             if (!($curlm_error_code === CURLM_OK)) {
                 throw new \ErrorException('cURL multi add handle error: ' . curl_multi_strerror($curlm_error_code));
             }
         }
         foreach ($this->curls as $ch) {
             foreach ($this->options as $key => $value) {
                 $ch->setOpt($key, $value);
             }
         }
         do {
             curl_multi_select($curl_multi);
             $status = curl_multi_exec($curl_multi, $active);
         } while ($status === CURLM_CALL_MULTI_PERFORM || $active);
         while (!($info_array = curl_multi_info_read($curl_multi)) === false) {
             if (!($info_array['msg'] === CURLMSG_DONE)) {
                 continue;
             }
             foreach ($this->curls as $ch) {
                 if ($ch->curl === $info_array['handle']) {
                     $ch->curl_error_code = $info_array['result'];
                     break;
                 }
             }
         }
         foreach ($this->curls as $ch) {
             $this->exec($ch);
         }
     } else {
         $this->base_url = $url_mixed;
         $this->url = $this->buildURL($url_mixed, $data);
         $this->setOpt(CURLOPT_URL, $this->url);
         $this->setOpt(CURLOPT_CUSTOMREQUEST, 'GET');
         $this->setOpt(CURLOPT_HTTPGET, true);
         return $this->exec();
     }
 }
开发者ID:andela-fadebayo,项目名称:paga-demo,代码行数:56,代码来源:curl.php

示例5: addImmediate

 /**
  * Call curl_multi_add_handle().
  * @param resource $ch
  * @param Deferred $deferred
  */
 private function addImmediate($ch, Deferred $deferred = null)
 {
     $errno = curl_multi_add_handle($this->mh, $ch);
     if ($errno !== CURLM_OK) {
         // @codeCoverageIgnoreStart
         $msg = curl_multi_strerror($errno) . ": {$ch}";
         $deferred && $deferred->reject(new \RuntimeException($msg));
         return;
         // @codeCoverageIgnoreEnd
     }
     $this->added[(string) $ch] = $ch;
     $deferred && ($this->deferreds[(string) $ch] = $deferred);
 }
开发者ID:mpyw,项目名称:co,代码行数:18,代码来源:ManualScheduler.php

示例6: add

 /**
  * Call curl_multi_add_handle().
  * @param resource $ch
  * @return PromiseInterface
  */
 public function add($ch)
 {
     $deferred = new Deferred();
     $errno = curl_multi_add_handle($this->mh, $ch);
     if ($errno !== CURLM_OK) {
         // @codeCoverageIgnoreStart
         $msg = curl_multi_strerror($errno) . ": {$ch}";
         $deferred->reject(new \RuntimeException($msg));
         return $deferred->promise();
         // @codeCoverageIgnoreEnd
     }
     $this->added[(string) $ch] = $ch;
     $this->deferreds[(string) $ch] = $deferred;
     return $deferred->promise();
 }
开发者ID:mpyw,项目名称:co,代码行数:20,代码来源:AutoScheduler.php

示例7: var_dump

<?php

var_dump(strtolower(curl_multi_strerror(CURLM_OK)));
var_dump(strtolower(curl_multi_strerror(CURLM_BAD_HANDLE)));
开发者ID:badlamer,项目名称:hhvm,代码行数:4,代码来源:curl_multi_strerror_001.php

示例8: addHandle

 /**
  * Add Handle
  *
  * @access private
  * @param  $curl
  */
 private function addHandle($curl)
 {
     $curlm_error_code = curl_multi_add_handle($this->multi_curl, $curl->curl);
     if (!($curlm_error_code === CURLM_OK)) {
         throw new \ErrorException('cURL multi add handle error: ' . curl_multi_strerror($curlm_error_code));
     }
     $curl->beforeSend($this->before_send_function);
     $curl->success($this->success_function);
     $curl->error($this->error_function);
     $curl->complete($this->complete_function);
     $this->curls[] = $curl;
     $curl->id = count($this->curls);
 }
开发者ID:aguillem,项目名称:festival-manager,代码行数:19,代码来源:MultiCurl.php

示例9: throwMultiError

 /**
  * Throw an exception for a cURL multi response
  *
  * @param int $code Curl response code
  * @throws AdapterException
  */
 public static function throwMultiError($code)
 {
     $buffer = function_exists('curl_multi_strerror') ? curl_multi_strerror($code) : self::ERROR_STR;
     throw new AdapterException(sprintf('cURL error %s: %s', $code, $buffer));
 }
开发者ID:ChenOhayon,项目名称:sitepoint_codes,代码行数:11,代码来源:MultiAdapter.php

示例10: strerror

 /**
  * @see curl_multi_strerror
  *
  * @param int $errornum
  * @return string
  */
 public static function strerror($errornum)
 {
     return curl_multi_strerror($errornum);
 }
开发者ID:phpcurl,项目名称:curlwrapper,代码行数:10,代码来源:CurlMulti.php

示例11: getLastError

 /**
  * @note PHP 5.5.0
  *
  * @since 1.0
  *
  * @return string
  */
 public function getLastError()
 {
     return function_exists('curl_multi_strerror') ? curl_multi_strerror($this->lastErrorCode) : '';
 }
开发者ID:JeroenDeDauw,项目名称:http-request,代码行数:11,代码来源:AsyncCurlRequest.php

示例12: curlMultiStrerror

 /**
  * Return string describing error code
  *
  * @param int $errornum One of the CURLM error codes constants. 
  * @return string       Error string for valid error code, NULL otherwise.
  */
 public final function curlMultiStrerror($errornum)
 {
     return curl_multi_strerror($this->curl_multi_handle, $errornum);
 }
开发者ID:KVSun,项目名称:core_api,代码行数:10,代码来源:curl_multi.php

示例13: getError

 public function getError($errno)
 {
     return curl_multi_strerror($errno);
 }
开发者ID:cdcchen,项目名称:php-plus,代码行数:4,代码来源:MultiCUrl.php

示例14: sendRequestAsyn

 /**
  * 发送异步请求
  * @return void
  */
 public function sendRequestAsyn()
 {
     $mh = curl_multi_init();
     $ch_handles = array();
     // 遍历设置的连接
     foreach ($this->asynRequests as $request) {
         $ch = curl_init($request['url']);
         $this->setCurlOptions($ch, $request['options']);
         $ch_handles[] = $ch;
         // 添加$ch到$mh
         curl_multi_add_handle($mh, $ch);
     }
     $running = null;
     do {
         $mrc = curl_multi_exec($mh, $running);
         curl_multi_select($mh);
     } while ($running > 0);
     unset($running);
     if ($mrc !== CURLM_OK) {
         throw new \Exception(curl_multi_strerror($mrc), 1);
     }
     foreach ($ch_handles as $key => $ch) {
         $this->headerInfo = curl_getinfo($ch);
         $this->asynResponses[$key] = new \stdClass();
         $this->asynResponses[$key]->response = curl_multi_getcontent($ch);
         $this->asynResponses[$key]->responseBody = $this->parseResultBody($this->asynResponses[$key]->response);
         $this->asynResponses[$key]->responseHeaders = $this->parseResultHeaders($this->asynResponses[$key]->response);
         curl_multi_remove_handle($mh, $ch);
     }
     curl_multi_close($mh);
 }
开发者ID:leoding86,项目名称:baidu-service,代码行数:35,代码来源:Request.php

示例15: fetchAsyncRequests

 /**
  * @param resource $asyncHandle
  * @param array &$asyncPendingRequests
  * @param array &$asyncProcessingRequests
  * @param array $asyncOptions
  * @return bool
  */
 private static function fetchAsyncRequests($asyncHandle, &$asyncPendingRequests, &$asyncProcessingRequests, $asyncOptions)
 {
     $pendingRequestCount = count($asyncPendingRequests);
     $processingRequestCount = count($asyncProcessingRequests);
     $maxConcurrentRequests = self::getAsyncMaxConcurrentRequests($asyncOptions);
     $requestFetchingCallback = self::getAsyncRequestFetchingCallback($asyncOptions);
     $isFetchingCallbackInvoked = false;
     while ($processingRequestCount < $maxConcurrentRequests) {
         if ($pendingRequestCount === 0) {
             if ($isFetchingCallbackInvoked) {
                 return true;
             }
             if ($requestFetchingCallback !== null) {
                 $tmp = call_user_func($requestFetchingCallback);
                 if ($tmp === false) {
                     return false;
                 } elseif ($tmp === true || $tmp === null) {
                     return true;
                 } elseif (is_array($tmp) === false) {
                     $type = gettype($tmp);
                     throw new WebClientAsyncException("The return value of request fetching callback must" . " be an array or a bool, {$type} given.");
                 }
                 $pendingRequestCount = count($tmp);
                 if ($pendingRequestCount === 0) {
                     return true;
                 }
                 $asyncPendingRequests = $tmp;
                 $isFetchingCallbackInvoked = true;
             } else {
                 return false;
             }
         }
         $key = key($asyncPendingRequests);
         $client = $asyncPendingRequests[$key];
         unset($asyncPendingRequests[$key]);
         --$pendingRequestCount;
         ++$processingRequestCount;
         if (is_array($client)) {
             $tmp = new static();
             $tmp->setOptions($client);
             $client = $tmp;
         } elseif ($client instanceof WebClient === false) {
             $type = gettype($client);
             throw new WebClientAsyncException('The request must be an instance of ' . __CLASS__ . " or an option array, {$type} given.");
         }
         $client->requestOptions = $client->options;
         $client->initializeRequest();
         $index = (int) $client->handle;
         if (isset($asyncProcessingRequests[$index])) {
             throw new WebClientAsyncException('The web client already exists in the processing queue.');
         }
         $asyncProcessingRequests[$index] = $client;
         $code = curl_multi_add_handle($asyncHandle, $client->handle);
         if ($code !== CURLM_OK) {
             throw new WebClientAsyncException(curl_multi_strerror($code), $code);
         }
     }
     return true;
 }
开发者ID:hyperframework,项目名称:hyperframework,代码行数:66,代码来源:WebClient.php


注:本文中的curl_multi_strerror函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。