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


PHP Curl::execute方法代码示例

本文整理汇总了PHP中Curl::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP Curl::execute方法的具体用法?PHP Curl::execute怎么用?PHP Curl::execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Curl的用法示例。


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

示例1: get

 public function get($uriParams = [])
 {
     if (is_array($uriParams)) {
         $uriParams = '?' . http_build_query($uriParams);
     } elseif (!is_string($uriParams)) {
         throw new Exception('Unsupported variable type');
     }
     $this->curl->setUrl($this->curl->getUrl() . $uriParams);
     return $this->curl->execute();
 }
开发者ID:chenshuhao,项目名称:BeginShake,代码行数:10,代码来源:Client.php

示例2: execute

 public function execute()
 {
     $result = parent::execute();
     if ($result === FALSE) {
         return FALSE;
     } else {
         $header = substr($result, 0, $this->info['header_size']);
         $body = substr($result, $this->info['header_size']);
         $header = explode("\n", $header);
         $headers = array();
         foreach ($header as $h) {
             $h = trim($h);
             if (empty($h)) {
                 continue;
             }
             $hd = explode(':', $h);
             if (count($hd) > 1) {
                 $headers[trim($hd[0])] = trim($hd[1]);
             } else {
                 $headers[trim($hd[0])] = trim($hd[0]);
             }
         }
         $this->response_headers = $headers;
         $this->response_body = $body;
         if ($this->info['http_code'] == 200) {
             return $this->response_body;
         } else {
             return FALSE;
         }
     }
 }
开发者ID:rip-projects,项目名称:ark-php,代码行数:31,代码来源:xcurl.php

示例3: initialize

 function initialize()
 {
     if (!$this->fetched) {
         $config =& get_config();
         $assetUrl = $config['asset_service'] . $this->node['AssetID'];
         $curl = new Curl();
         $curl->create($assetUrl);
         $curl->option(CURLOPT_HEADER, true);
         $curl->option(CURLOPT_NOBODY, true);
         $response = $curl->execute();
         if ($response) {
             $headers = http_parse_headers($response);
             $this->size = $headers['Content-Length'];
             $this->contentType = $headers['Content-Type'];
             if (isset($headers['ETag'])) {
                 $this->etag = $headers['ETag'];
             } else {
                 if (isset($headers['Etag'])) {
                     $this->etag = $headers['Etag'];
                 } else {
                     $this->etag = '';
                 }
             }
         } else {
             log_message('error', "InventoryFile: Failed to fetch headers from {$assetUrl}");
         }
         $this->fetched = true;
     }
 }
开发者ID:QuillLittlefeather,项目名称:mgm-simiangrid,代码行数:29,代码来源:Class.InventoryFile.php

示例4: execute

 public function execute()
 {
     $curl_options = array(CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_URL => $this->generate_url());
     $curl = new Curl($curl_options);
     $res = $curl->execute();
     return json_decode($res);
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:7,代码来源:Url_Shortner.php

示例5: execute

 /**
  * @throws PrimePesaException
  * @throws \Exception
  */
 public function execute()
 {
     $params = array();
     $params['cmd'] = 'balance';
     $params['secret_key'] = $this->getSecretKey();
     $result = Curl::execute($params);
     $this->_assertNotError($result);
     $this->result = $result;
 }
开发者ID:primepesa,项目名称:primepesa,代码行数:13,代码来源:Balance.php

示例6: isAuthentic

 /**
  * @return bool
  * @throws PrimePesaException
  * @throws \Exception
  */
 public function isAuthentic()
 {
     $params = array();
     $params['cmd'] = 'verify';
     $params['secret_key'] = $this->getSecretKey();
     $params = array_merge($params, $this->data);
     $results = Curl::execute($params);
     $this->_assertNotError($results);
     return $results['status'] == 'VERIFIED';
 }
开发者ID:primepesa,项目名称:primepesa,代码行数:15,代码来源:IPNNotification.php

示例7: get

 function get($url, $userAgent = '', $httpHeaders = '', $username = '', $password = '')
 {
     $ret = Curl::execute('GET', $url, '', $userAgent, $httpHeaders, $username, $password);
     if (false === $ret) {
         return false;
     }
     if (is_array($ret)) {
         return false;
     }
     return $ret;
 }
开发者ID:Bingle-labake,项目名称:coollive.com.cn,代码行数:11,代码来源:curl.php

示例8: url_exists

 /**
  * url_exists function.
  * Checks to see if an url exists
  * 
  * @access public
  * @param string $url
  * @return bool
  */
 public static function url_exists($url)
 {
     $curl_options = array(CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_URL => $url);
     $curl = new Curl($curl_options);
     try {
         $curl->execute();
         $error = FALSE;
     } catch (Exception $e) {
         $error = TRUE;
     }
     return $error;
 }
开发者ID:xig,项目名称:SocialFeed,代码行数:20,代码来源:socialFeed.php

示例9: create_asset

function create_asset($assetID, $creatorID, $contentType, $filename)
{
    $CI =& get_instance();
    $CI->load->library('Curl');
    $CI->load->helper('path');
    $filename = rtrim(set_realpath($filename), '/');
    $params = array('AssetID' => $assetID, 'CreatorID' => $creatorID, 'Asset' => "@{$filename};type={$contentType}");
    echo 'Posting ' . $filename . ' to ' . $CI->config->item('asset_service') . '<br/>';
    $curl = new Curl();
    $curl->create($CI->config->item('asset_service'));
    $curl->option(CURLOPT_POST, TRUE);
    $curl->option(CURLOPT_POSTFIELDS, $params);
    $curl->http_method('post');
    $response = json_decode($curl->execute(), TRUE);
    if (!isset($response)) {
        $response = array('Message' => 'Invalid or missing response. ' . $curl->error_string);
    }
    return $response;
}
开发者ID:QuillLittlefeather,项目名称:mgm-simiangrid,代码行数:19,代码来源:simian_helper.php

示例10: ping

 public static function ping()
 {
     $url = "http://" . $_SERVER['HTTP_HOST'] . '/admin/ping/technorati';
     $options = array(CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_URL => $url);
     $curl = new Curl($options);
     $curl->execute();
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:7,代码来源:zest.php

示例11: _zest_news

 public function _zest_news()
 {
     return "";
     $html = "<h2>Zest News</h2><hr/>";
     $url = "http://zestcms.com/rss/4";
     $curl_options = array(CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_URL => $url);
     $curl = new Curl($curl_options);
     $data = new SimpleXMLElement($curl->execute());
     $data = $data->channel->item;
     $arr = array();
     $i = 0;
     foreach ($data as $item) {
         if ($i == 5) {
             break;
         }
         $arr[] = $item;
         $i++;
     }
     $arr = array_reverse($arr);
     foreach ($arr as $item) {
         $html .= "<p>" . date('d M', strtotime($item->pubDate)) . "<br/><a href='" . $item->link . "' target='_BLANK'>" . $item->title . "</a></p><hr/>";
     }
     return $html;
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:24,代码来源:zest_admin.php

示例12: requestCache

 /**
  * @param string   $url
  * @param Curl     $curl
  * @param callable $callback
  * @param int      $maxAge
  * @param bool     $refreshInBackground
  * @return mixed
  */
 public static function requestCache($url, Curl $curl = null, $callback = null, $maxAge = self::DEFAULT_CACHE_MAX_AGE, $refreshInBackground = true)
 {
     $return = false;
     $returnValue = null;
     if (!$curl) {
         $curl = new Curl();
         $return = true;
         $callback = function ($content) use(&$returnValue) {
             $returnValue = $content;
         };
     }
     $stmt = self::getStatement('SELECT * FROM request_cache WHERE url = ?');
     $stmt->execute(array($url));
     $stmt->bindColumn('timestamp', $timestamp);
     $stmt->bindColumn('etag', $etag);
     $stmt->bindColumn('content', $content);
     $stmt->bindColumn('refresh', $refresh);
     $stmt->fetch(PDO::FETCH_BOUND);
     $shouldRefresh = $timestamp < time() - 60 * $maxAge;
     $refreshInBackground = $refreshInBackground && !is_null($content);
     if ($shouldRefresh && $refreshInBackground && $refresh < time() - 60) {
         self::getStatement('UPDATE request_cache SET refresh = ? WHERE url = ?')->execute(array(time(), $url));
         self::$refreshUrls[] = $url;
     }
     if (!$shouldRefresh || $refreshInBackground) {
         $content = json_decode($content);
         $stmt = self::getStatement('SELECT url, content FROM request_cache WHERE parent = ? ORDER BY `timestamp` DESC');
         while ($stmt->execute(array($url)) && ($data = $stmt->fetchObject())) {
             $content = array_merge($content, json_decode($data->content));
             $url = $data->url;
         }
         if (is_callable($callback)) {
             $callback($content);
         }
         return $returnValue;
     }
     $responses = array();
     $handleResponse = function (CurlResponse $response, $content, $parent = null) use(&$handleResponse, $curl, &$responses, $stmt, $callback) {
         $url = $response->request->url;
         if ($response && in_array($response->status, array(200, 304))) {
             $checkNext = false;
             if (304 == $response->status) {
                 $response->content = $content;
                 $checkNext = true;
             } elseif (false === stripos($response->contentType, 'json')) {
                 $response->content = json_encode($response->content);
             }
             $responses[] = $response->content;
             Workflow::getStatement('REPLACE INTO request_cache VALUES(?, ?, ?, ?, 0, ?)')->execute(array($url, time(), $response->etag, $response->content, $parent));
             if ($checkNext || $response->link && preg_match('/<(.+)>; rel="next"/U', $response->link, $match)) {
                 $stmt = Workflow::getStatement('SELECT * FROM request_cache WHERE parent = ?');
                 $stmt->execute(array($url));
                 if ($checkNext) {
                     $stmt->bindColumn('url', $nextUrl);
                 } else {
                     $nextUrl = $match[1];
                 }
                 $stmt->bindColumn('etag', $etag);
                 $stmt->bindColumn('content', $content);
                 $stmt->fetch(PDO::FETCH_BOUND);
                 if ($nextUrl) {
                     $curl->add(new CurlRequest($nextUrl, $etag, function (CurlResponse $response) use($handleResponse, $url, $content) {
                         $handleResponse($response, $content, $url);
                     }));
                     return;
                 }
             } else {
                 Workflow::getStatement('DELETE FROM request_cache WHERE parent = ?')->execute(array($url));
             }
         } else {
             Workflow::getStatement('DELETE FROM request_cache WHERE url = ?')->execute(array($url));
             $url = null;
         }
         if (is_callable($callback)) {
             if (empty($responses)) {
                 $callback(array());
                 return;
             }
             if (1 === count($responses)) {
                 $callback(json_decode($responses[0]));
                 return;
             }
             $callback(array_reduce($responses, function ($content, $response) {
                 return array_merge($content, json_decode($response));
             }, array()));
         }
     };
     $curl->add(new CurlRequest($url, $etag, function (CurlResponse $response) use(&$responses, $handleResponse, $callback, $content) {
         $handleResponse($response, $content);
     }));
     if ($return) {
         $curl->execute();
//.........这里部分代码省略.........
开发者ID:njql007,项目名称:alfred-github-workflow,代码行数:101,代码来源:workflow.php

示例13: connect

 /**
  * cURL connection function. Returns data from Twitter and interfaces with
  * debug function.
  *
  * @param   bool    $login			Login to Twitter?
  * @param   bool    $post			Use POST instead of GET?
  * @param   array    $post_data		Array data for POST.
  * @return  string
  */
 private function connect($login = FALSE, $post = FALSE, $post_data = NULL)
 {
     // If credentials are required add them
     if ($login) {
         $login = $this->login;
     }
     // add default header info
     $this->headers[] = 'Expect:';
     $curl_options = array(CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_URL => $this->url);
     // curl init
     $curl = new Curl($curl_options);
     // add curl options
     if (count($this->headers) > 0) {
         $curl->addOption(CURLOPT_HTTPHEADER, $this->headers);
     }
     if ($login) {
         $curl->addOption(CURLOPT_USERPWD, $this->login);
     }
     if ($post) {
         $curl->addOption(CURLOPT_POST, TRUE);
     }
     if (is_array($post_data)) {
         $curl->addOption(CURLOPT_POSTFIELDS, $post_data);
     }
     // retrieve data
     $data = $curl->execute($this->ignore_curl_error_numbers);
     // set curl http status
     $this->status = $curl->status();
     // set last call
     $this->last = $this->url;
     // clear settings
     $this->url = '';
     $this->headers = '';
     // debug output
     //	if (!IN_PRODUCTION AND Kohana::config('twitter.debug')) $this->debugo($data, $post_data);
     return $data;
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:46,代码来源:Twitter.php

示例14: check_for_feed

 /**
  * check_for_feed function.
  * 
  * @access public
  * @param string $url
  * @return boolean
  */
 public function check_for_feed($url)
 {
     $query = "select title,href from html where url='" . $url . "' and xpath='//link' and type='application/rss+xml'";
     $q = urlencode($query);
     $url = 'http://query.yahooapis.com/v1/public/yql?q=' . $q . '&format=json';
     $curl_options = array(CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_URL => $url);
     $curl = new Curl($curl_options);
     $data = $curl->execute();
     $data = json_decode($data);
     if (!isset($data->error) && isset($data->query->results)) {
         if (is_array($data->query->results->link)) {
             foreach ($data->query->results->link as $link) {
                 if (isset($link->href) && strstr($link->href, 'http://') != FALSE) {
                     $this->feeds[$link->title] = array("profile" => $url, "feed" => str_replace('&lang', '&amp;lang', $link->href));
                 }
             }
         } else {
             if (isset($data->query->results->link->href) && strstr($data->query->results->link->href, 'http://') != FALSE) {
                 $this->feeds[$data->query->results->link->title] = array("profile" => $url, "feed" => str_replace('&lang', '&amp;lang', $data->query->results->link->href));
             }
         }
         return TRUE;
     } else {
         return FALSE;
     }
 }
开发者ID:xig,项目名称:SocialFeed,代码行数:33,代码来源:Site_scraper.php

示例15: mulitGet

 public function mulitGet($urls)
 {
     $curl = new Curl();
     $curl->setUrls($urls);
     return $curl->execute();
 }
开发者ID:xiaojiays,项目名称:curl,代码行数:6,代码来源:CurlService.php


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