本文整理汇总了PHP中EpiCurl类的典型用法代码示例。如果您正苦于以下问题:PHP EpiCurl类的具体用法?PHP EpiCurl怎么用?PHP EpiCurl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EpiCurl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($url, $depth = 3, $limitUrls = 59)
{
$this->_url = $url;
$this->_depth = $depth;
$parsed = parse_url($url);
$this->_host = $parsed['host'];
$this->_curl = \EpiCurl::getInstance();
$this->_limitUrls = $limitUrls;
$this->_pool = new \Pool(10);
}
开发者ID:alfchee,项目名称:PaypalTest,代码行数:10,代码来源:Crawler.php
示例2: __call
public function __call($name, $params = null)
{
$parts = explode('_', $name);
$method = strtoupper(array_shift($parts));
$parts = implode('_', $parts);
$path = '/' . preg_replace('/[A-Z]|[0-9]+/e', "'/'.strtolower('\\0')", $parts) . '.json';
$args = !empty($params) ? array_shift($params) : null;
// intercept calls to the search api
if (preg_match('/^(search|trends)/', $parts)) {
$query = isset($args) ? http_build_query($args) : '';
$url = "{$this->searchUrl}{$path}?{$query}";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
return new EpiTwitterJson(EpiCurl::getInstance()->addCurl($ch));
}
$url = $this->getUrl("{$this->apiUrl}{$path}");
return new EpiTwitterJson(call_user_func(array($this, 'httpRequest'), $method, $url, $args));
}
开发者ID:abrahamvegh,项目名称:epicode,代码行数:18,代码来源:EpiTwitter.php
示例3: getVideoData
/**
* Get video data from Youtube API.
*
* @param string $video_url Video URL or video ID.
* @return array
*/
public function getVideoData($video_url)
{
$video_id = $this->_getVideoId($video_url);
$multi_curl = EpiCurl::getInstance();
$curl = curl_init($this->api_url . $video_id);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = $multi_curl->addCurl($curl);
if (200 !== $response->code) {
return false;
}
try {
$xml_data = @new SimpleXMLElement($response->data);
} catch (\Exception $e) {
if ('Invalid id' === $response->data) {
return false;
}
}
$video_data['video_id'] = $video_id;
$video_data['url_player'] = (string) $xml_data->link[0]->attributes()->href[0];
$media_group = $xml_data->children($this->media_namespace);
$video_data['title'] = (string) $media_group->group->title;
$video_data['description'] = (string) $media_group->group->description;
$video_data['keywords'] = explode(',', (string) $media_group->group->keywords);
if (!isset($media_group->group->content[0])) {
return false;
}
$content_attrs = $media_group->group->content[0]->attributes();
$video_data['url_embed'] = (string) $content_attrs['url'];
$video_data['duration'] = (int) $content_attrs['duration'];
foreach ($media_group->group->thumbnail as $key => $val) {
$thumb_attrs = $val->attributes();
$thumb_width = (int) $thumb_attrs['width'];
if ($thumb_width == 120) {
$video_data['thumbnails'][] = (string) $thumb_attrs['url'];
}
}
return $video_data;
}
开发者ID:ninodafonte,项目名称:SIFO,代码行数:44,代码来源:Youtube.php
示例4: request
private function request($method, $endpoint, $params = null, $username = null, $password = null)
{
if (preg_match('#^https?://#', $endpoint)) {
$url = $endpoint;
} else {
$url = $this->getApiUrl($endpoint);
}
if ($this->accessToken) {
$params['oauth_token'] = $this->accessToken;
}
if ($method === 'GET') {
$url .= is_null($params) ? '' : '?' . http_build_query($params, '', '&');
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->requestTimeout);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
if ($method === 'POST' && $params !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
}
$resp = new EpiFoursquareJson(EpiCurl::getInstance()->addCurl($ch), $this->debug);
if (!$this->isAsynchronous) {
$resp->responseText;
}
return $resp;
}
开发者ID:rspindel,项目名称:foursquare-async,代码行数:27,代码来源:EpiFoursquare.php
示例5: nonblock_post
function nonblock_post($url, $data)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_COOKIEFILE, $this->cookie_file);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$mc = EpiCurl::getInstance();
$curl1 = $mc->addCurl($curl);
}
开发者ID:dalinhuang,项目名称:shopexts,代码行数:18,代码来源:shopex_flood.php
示例6: dirname
<?php
include dirname(__FILE__) . '/../EpiCurl.php';
include dirname(__FILE__) . '/../EpiOAuth.php';
include dirname(__FILE__) . '/../EpiTwitter.php';
include dirname(__FILE__) . '/../EpiSequence.php';
$consumer_key = 'jdv3dsDhsYuJRlZFSuI2fg';
$consumer_secret = 'NNXamBsBFG8PnEmacYs0uCtbtsz346OJSod7Dl94';
$token = '25451974-uakRmTZxrSFQbkDjZnTAsxDO5o9kacz2LT6kqEHA';
$secret = 'CuQPQ1WqIdSJDTIkDUlXjHpbcRao9lcKhQHflqGE8';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret, $token, $secret);
$twitterObj->useAsynchronous(true);
?>
Test sequencing diagram of api calls
<?php
$creds = array();
$creds[] = $twitterObj->get('/direct_messages.json');
$creds[] = $twitterObj->get('/users/suggestions.json');
$creds[] = $twitterObj->get('/statuses/public_timeline.json');
foreach ($creds as $cred) {
$cred->responseText;
}
echo EpiCurl::getSequence()->renderAscii();
开发者ID:neostoic,项目名称:SpaceNeedle,代码行数:25,代码来源:sequencerTest.php
示例7: __construct
public function __construct($consumerKey = "BBE15ugu1VLyJUxhxlgYQ", $consumerSecret = "2KVw2TRS9xXhGapSeR3RaUpuM2SY6kpiUUYEHWgQ", $signatureMethod = 'HMAC-SHA1')
{
$this->consumerKey = $consumerKey;
$this->consumerSecret = $consumerSecret;
$this->signatureMethod = $signatureMethod;
$this->curl = EpiCurl::getInstance();
}
开发者ID:mbcraft,项目名称:frozen,代码行数:7,代码来源:EpiOAuth.class.php
示例8: _updateFeeds
/**
* Loads all the feeds from the cache or new from the server
*
* @version 1.0.0
* @since Version 1.0.0
* @access private
* @return array An array of RSS feed XML
**/
public function _updateFeeds()
{
$EE =& get_instance();
libxml_use_internal_errors(true);
require_once PATH_THIRD . NSM_ADDON_UPDATER_ADDON_ID . "/libraries/Epicurl.php";
$sources = false;
$feeds = false;
$mc = EpiCurl::getInstance();
foreach ($EE->addons->_packages as $addon_id => $addon) {
$config_file = PATH_THIRD . '/' . $addon_id . '/config.php';
if (!file_exists($config_file)) {
continue;
}
include $config_file;
$data = false;
# Is there a file with the xml url?
if (isset($config['nsm_addon_updater']['versions_xml'])) {
$url = $config['nsm_addon_updater']['versions_xml'];
# Get the XML again if it isn't in the cache
if ($this->test_mode || !($response = $this->_readCache(md5($url)))) {
log_message('debug', "Checking for updates via CURL: {$addon_id}");
$c = false;
$c = curl_init($url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
@curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
$curls[$addon_id] = $mc->addCurl($c);
$response = $curls[$addon_id]->data;
$this->_createCacheFile($response, md5($url));
// if theres an error with the curl request set an error
if (!in_array($curls[$addon_id]->code, array(200, 301, 302))) {
$data = array('error' => 'Could not find changelog for add-on', 'row_class' => 'error');
}
}
if (!isset($data['error'])) {
# If there isn't an error with the XML
try {
$xml = @simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA);
$data = $xml;
} catch (Exception $e) {
// problem with data
$data = false;
}
}
// data still false? mark as an error
if (!$data) {
$data = array('error' => "There was a problem processing the <a href='{$config['nsm_addon_updater']['versions_xml']}' target='_blank'>versions.xml</a> file for this add-on", 'row_class' => 'error');
}
} else {
if (!$this->hide_incompatible) {
$data = array('error' => 'Addon doesn\'t have a NSM Addon Updater URL', 'row_class' => '');
}
}
if ($data) {
$feeds[$addon_id] = $data;
}
unset($config);
}
return $feeds;
}
开发者ID:newism,项目名称:nsm.addon_updater.ee_addon,代码行数:67,代码来源:acc.nsm_addon_updater.php
示例9: _out
/**
* Performs heavy lifting of plugin, processing output and returning final tags
* [Adapted from CodeIgniter Carabiner library]
*
* @return string The final tag to be returned to template
*/
private function _out()
{
// our return variable
$out = '';
// if we are not combining, then minify each file in turn
if ($this->combine == 'no') :
$tags = array();
foreach ($this->filesdata as $key => $file) :
$this->filesdata[$key]['cache_filename'] = $file['lastmodified'] . md5($file['name']) . '.' . $this->type;
if (file_exists($this->EE->functions->remove_double_slashes($this->cache_path . '/' . $this->filesdata[$key]['cache_filename'])))
{
log_message('debug', 'Minimee is returning a cached file: ' . $this->EE->functions->remove_double_slashes($this->cache_path . '/' . $this->filesdata[$key]['cache_filename']));
$tags[$key] = $this->_tag($this->filesdata[$key]['cache_filename']);
}
else
{
// must get contents of file to minify
switch ($file['type']) :
case ('stylesheet');
case ('remote') :
switch ($this->remote_mode)
{
case ('fgc') :
// I hate to suppress errors, but it's only way to avoid one from a 404 response
$response = @file_get_contents($file['name']);
if ($response && isset($http_response_header) && (substr($http_response_header[0], 9, 3) < 400))
{
$this->_cache($this->filesdata[$key]['cache_filename'], $this->_minify($response));
$tags[$key] = $this->_tag($this->filesdata[$key]['cache_filename']);
}
else
{
throw new Exception('A problem occurred while fetching the following over file_get_contents(): ' . $file['name']);
}
break;
case ('curl') :
if ( ! isset($epicurl))
{
require_once(PATH_THIRD . 'minimee/libraries/EpiCurl.php');
$epicurl = EpiCurl::getInstance();
}
$ch = FALSE;
$ch = curl_init($file['name']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$curls[$key] = $epicurl->addCurl($ch);
if ($curls[$key]->code >= 400)
{
throw new Exception('Error encountered while fetching \'' . $this->filesdata[$key]['name'] . '\' over cURL.');
}
$this->_cache($this->filesdata[$key]['cache_filename'], $this->_minify($curls[$key]->data));
$tags[$key] = $this->_tag($this->filesdata[$key]['cache_filename']);
break;
default :
throw new Exception('Could not fetch file \'' . $file['name'] . '\' because neither cURL or file_get_contents() appears available.');
break;
}
break;
case ('local') :
default :
$rel = dirname($this->EE->functions->remove_double_slashes($this->base_url . '/' . $file['name'] . '/'));
$contents = file_get_contents(realpath($this->EE->functions->remove_double_slashes($this->base_path . '/' . $file['name']))) . "\n";
$this->_cache($this->filesdata[$key]['cache_filename'], $this->_minify($contents, $rel));
$tags[$key] = $this->_tag($this->filesdata[$key]['cache_filename']);
break;
endswitch;
}
endforeach;
$out = implode('', $tags);
// combine (& possibly minify) files
else :
$lastmodified = 0;
$cache_name = '';
//.........这里部分代码省略.........
开发者ID:rmdort,项目名称:adiee,代码行数:101,代码来源:pi.minimee.php
示例10: fetch
/**
* Fetches the given URL for every added account or a single URL if credentials aren't required.
*
* @param string $url Url to fetch.
* @param boolean $require_credentials Whether user needs to be authenticated or not.
* @param boolean $http_post Send data as a POST.
* @return array
*/
public function fetch()
{
$mc = EpiCurl::getInstance();
foreach (self::$accounts as $account_name => $values) {
foreach ($values['methods'] as $method_name => $method) {
$curl_handle = curl_init($method['url']);
// Due to headers' lios: http://www.shoemoney.com/2008/12/29/lib-curl-twitter-api-expect-100-continue-pain-and-how-to-fix-it/
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
// x seconds for timeout
curl_setopt($curl_handle, CURLOPT_TIMEOUT, 5);
if ($method['require_credentials']) {
curl_setopt($curl_handle, CURLOPT_USERPWD, $values['credentials']);
}
if ($method['http_post']) {
curl_setopt($curl_handle, CURLOPT_POST, true);
}
self::$accounts[$account_name][$method_name]['curl'] = $mc->addCurl($curl_handle);
}
}
foreach (self::$accounts as $account_name => $values) {
foreach ($values['methods'] as $method_name => $value) {
self::$accounts[$account_name][$method_name] = self::$accounts[$account_name][$method_name]['curl']->data;
// ->code can be returned as well.
}
// Finished with all this account methods, unset:
unset(self::$accounts[$account_name]['methods']);
unset(self::$accounts[$account_name]['credentials']);
unset(self::$accounts[$account_name]['curl']);
}
if (empty(self::$accounts[self::NO_ACCOUNT_NAME])) {
unset(self::$accounts[self::NO_ACCOUNT_NAME]);
}
return self::$accounts;
}
开发者ID:ninodafonte,项目名称:SIFO,代码行数:43,代码来源:Twitter.php
示例11: get_update_feeds
private function get_update_feeds()
{
require APPPATH . "third_party/nsm_addon_updater/libraries/Epicurl.php";
$sources = FALSE;
$feeds = FALSE;
$mc = EpiCurl::getInstance();
foreach ($this->EE->extensions->OBJ as $addon_id => $addon) {
if (isset($addon->versions_xml)) {
if (!($xml = $this->get_cache($addon->versions_xml))) {
$c = FALSE;
$c = curl_init($addon->versions_xml);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
$curls[$addon_id] = $mc->addCurl($c);
$xml = FALSE;
if ($curls[$addon_id]->code == "200" || $curls[$addon_id]->code == "302") {
$xml = $curls[$addon_id]->data;
$this->write_cache($xml, $addon->versions_xml);
}
}
if ($xml = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)) {
$feeds[$addon_id] = $xml;
}
}
}
return $feeds;
}
开发者ID:shapeshed,项目名称:nsm.addon_updater.ee_addon,代码行数:27,代码来源:ext.nsm_addon_updater.php
示例12: array
"Name":"Feast of Veggie Pizzas",
"Rating":125,
"Type":8,
"Count":1,
"CreatedItemId":12602,
"RequiresRecipeItem":true,
"Ingredients":[{"ItemID":12346,"Count":10}]}
}
}
*/
//Quick and dirty discipline name to ID translation.
$disciplines = array('Huntsman' => 1, 'Artificer' => 2, 'Weaponsmith' => 3, 'Armorsmith' => 4, 'Leatherworker' => 5, 'Tailor' => 6, 'Jeweler' => 7, 'Chef' => 8);
//Gather all recipes by recipe_id
$curl = CurlRequest::newInstance(getAppConfig('gw2spidy.gw2api_url') . "/v1/recipes.json")->exec();
$data = json_decode($curl->getResponseBody(), true);
$multi_curl = EpiCurl::getInstance();
$recipe_curls = array();
$recipe_count = count($data['recipes']);
$error_values = array();
$i = 0;
$ii = 0;
foreach (array_chunk($data['recipes'], 1000) as $recipes) {
//Add all curl requests to the EpiCurl instance.
foreach ($recipes as $recipe_id) {
$i++;
$ch = curl_init(getAppConfig('gw2spidy.gw2api_url') . "/v1/recipe_details.json?recipe_id={$recipe_id}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$recipe_curls[$recipe_id] = $multi_curl->addCurl($ch);
echo "[{$i} / {$recipe_count}]: {$recipe_id}\n";
}
foreach ($recipes as $recipe_id) {
开发者ID:keneanung,项目名称:gw2spidy,代码行数:31,代码来源:create-recipe-map.php
示例13: run
public function run()
{
$curl = EpiCurl::getInstance();
$newUrl = $this->checkHeaders($this->url);
$this->response = file_get_contents($this->url);
//$curl->addURL($newUrl);
// var_dump($this->response);die();
}
开发者ID:alfchee,项目名称:TestDomPDF,代码行数:8,代码来源:crawler.php
示例14: __construct
public function __construct($access, $secret)
{
$this->accessID = $access;
$this->secretKey = $secret;
$this->curl = EpiCurl::getInstance();
}
开发者ID:alfchee,项目名称:TestDomPDF,代码行数:6,代码来源:CKMoz.php
示例15:
static function &getInstance($fbId = null)
{
static $inst = null;
$class = __CLASS__;
if ($inst === null) {
$inst = new $class();
$inst->apikey = '03f99def50e358c05b3855039c85d097';
$inst->secret = '9cd9d117a7d2112e80448eb15c41fd11';
$inst->fbId = '500273081';
//$fbId;
$inst->version = '1.0';
$inst->curl = EpiCurl::getInstance();
}
return $inst;
}
开发者ID:jmathai,项目名称:photos,代码行数:15,代码来源:CFacebook.php
示例16: __construct
function __construct($key)
{
$this->key = $key;
$this->epiCurl = EpiCurl::getInstance();
}
开发者ID:samthomson,项目名称:php-multi-curl,代码行数:5,代码来源:EpiCurl.php
示例17: __construct
public function __construct($consumerKey, $consumerSecret, $signatureMethod = 'HMAC-SHA1')
{
$this->consumerKey = $consumerKey;
$this->consumerSecret = $consumerSecret;
$this->signatureMethod = $signatureMethod;
$this->curl = EpiCurl::getInstance();
}
开发者ID:meishern,项目名称:simplenewsbot,代码行数:7,代码来源:EpiOAuth.php
示例18:
<?php
include 'EpiCurl.php';
$mc = EpiCurl::getInstance();
$yahoo = $mc->addURL('http://www.yahoo.com');
// call yahoo
$google = $mc->addURL('http://www.google.com');
// call google
$ebay = $mc->addURL('http://www.ebay.com');
// call ebay
// fetch response from yahoo and google
echo "The response code from Yahoo! was {$yahoo->code}\n";
echo "The response code from Google was {$google->code}\n";
$microsoft = $mc->addURL('http://www.microsoft.com');
// call microsoft
// fetch response from ebay and microsoft
echo "The response code from Ebay was {$ebay->code}\n";
echo "The response code from Microsoft was {$microsoft->code}\n";
开发者ID:samthomson,项目名称:php-multi-curl,代码行数:18,代码来源:example.php
示例19: request_basic
private function request_basic($method, $endpoint, $params = null, $username = null, $password = null)
{
$url = $this->getApiUrl($endpoint);
if ($method === 'GET') {
$url .= is_null($params) ? '' : '?' . http_build_query($params, '', '&');
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->requestTimeout);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
if ($method === 'POST' && $params !== null) {
if ($this->isMultipart($params)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
} else {
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->buildHttpQueryRaw($params));
}
}
if (!empty($username) && !empty($password)) {
curl_setopt($ch, CURLOPT_USERPWD, "{$username}:{$password}");
}
$resp = new EpiTwitterJson(EpiCurl::getInstance()->addCurl($ch), $this->debug);
if (!$this->isAsynchronous) {
$resp->response;
}
return $resp;
}
开发者ID:rifal89,项目名称:twitter-async,代码行数:27,代码来源:EpiTwitter.php
示例20: request
private function request($method, $endpoint, $params = null)
{
if (preg_match('#^https?://#', $endpoint)) {
$url = $endpoint;
} else {
$url = $this->getApiUrl($endpoint);
}
if ($this->accessToken) {
$params['access_token'] = $this->accessToken;
}
$params['client_id'] = $this->clientId;
$params['client_secret'] = $this->clientSecret;
if ($method === 'GET' || $method === 'DELETE') {
$url .= is_null($params) ? '' : '?' . http_build_query($params, '', '&');
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->requestTimeout);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
if (isset($_SERVER['SERVER_ADDR']) && !empty($_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR'] != '127.0.0.1') {
curl_setopt($ch, CURLOPT_INTERFACE, $_SERVER['SERVER_ADDR']);
}
if ($method === 'POST' && $params !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
}
$resp = new InstagramJson(EpiCurl::getInstance()->addCurl($ch), $this->debug);
if (!$this->isAsynchronous) {
$resp->responseText;
}
return $resp;
}
开发者ID:0trebor0,项目名称:php-instagram,代码行数:35,代码来源:CheInstagram.php
注:本文中的EpiCurl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论