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


PHP curl类代码示例

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


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

示例1: verifyToken

 protected function verifyToken()
 {
     $gAuthServerConfig = $this->settings['App_auth'];
     if (!$gAuthServerConfig) {
         $this->user = array('user_id' => $this->input['user_id'], 'user_name' => $this->input['user_name'], 'group_type' => 1, 'appid' => $this->input['appid'], 'display_name' => $this->input['user_name'], 'visit_client' => 0);
         return;
     }
     if (!class_exists('curl')) {
         include_once ROOT_PATH . 'lib/class/curl.class.php';
     }
     $curl = new curl($gAuthServerConfig['host'], $gAuthServerConfig['dir']);
     $curl->initPostData();
     $postdata = array('appid' => $this->input['appid'], 'appkey' => $this->input['appkey'], 'access_token' => $this->input['access_token'], 'mod_uniqueid' => MOD_UNIQUEID, 'app_uniqueid' => APP_UNIQUEID, 'a' => 'get_user_info');
     foreach ($postdata as $k => $v) {
         $curl->addRequestData($k, $v);
     }
     $ret = $curl->request('get_access_token.php');
     //判定终端是否需要登录授权
     if ($ret['ErrorCode']) {
         $this->errorOutput($ret['ErrorCode']);
     }
     $this->user = $ret[0];
     if ($this->input['m2o_ckey'] == CUSTOM_APPKEY) {
         $this->user['group_type'] = 1;
     }
 }
开发者ID:h3len,项目名称:Project,代码行数:26,代码来源:configuare.php

示例2: readFeed

 function readFeed($url, $type = '')
 {
     $this->url = $url;
     $this->type = $type;
     $urltocapture = new curl($this->url);
     $urltocapture->setopt(CURLOPT_HTTPGET, true);
     $this->fileRead = $urltocapture->exec();
     if (empty($this->fileRead) or !$this->fileRead) {
         return 101;
     }
     $ext = new btext();
     $this->feedArray = $ext->xml2array($this->fileRead);
     switch ($this->type) {
         case 'youtube':
             return $this->youtube();
             break;
         case 'vimeo':
             return $this->vimeo();
             break;
         case 'dailymotion':
             return $this->dailymotion();
             break;
         default:
             return false;
             break;
     }
 }
开发者ID:iionly,项目名称:izap_videos,代码行数:27,代码来源:getFeed.php

示例3: moodle_simplepie_file

 /**
  * The contructor is a copy of the stock simplepie File class which has
  * been modifed to add in use the Moodle curl class rather than php curl
  * functions.
  */
 function moodle_simplepie_file($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)
 {
     $this->url = $url;
     $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
     $curl = new curl();
     $curl->setopt(array('CURLOPT_HEADER' => true));
     try {
         $this->headers = $curl->get($url);
     } catch (moodle_exception $e) {
         $this->error = 'cURL Error: ' . $curl->error;
         $this->success = false;
         return false;
     }
     $parser =& new SimplePie_HTTP_Parser($this->headers);
     if ($parser->parse()) {
         $this->headers = $parser->headers;
         $this->body = $parser->body;
         $this->status_code = $parser->status_code;
         if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) {
             $this->redirects++;
             $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
             return $this->SimplePie_File($location, $timeout, $redirects, $headers);
         }
     }
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:30,代码来源:moodle_simplepie.php

示例4: __getConfig

 public function __getConfig()
 {
     //获取mediaserver的里面视频类型的配置
     if ($this->settings['App_mediaserver']) {
         $curl = new curl($this->settings['App_mediaserver']['host'], $this->settings['App_mediaserver']['dir'] . 'admin/');
         $curl->setReturnFormat('json');
         $curl->initPostData();
         $curl->addRequestData('a', '__getConfig');
         $m_config = $curl->request('index.php');
     }
     if ($m_config && is_array($m_config)) {
         $video_type = $m_config[0]['video_type']['allow_type'];
     } else {
         $video_type = $this->default_type;
     }
     $video_type_arr = explode(',', $video_type);
     $flash_video_type = '';
     foreach ($video_type_arr as $k => $v) {
         $flash_video_type .= '*' . $v . ';';
     }
     $video_types = str_replace('.', '', $video_type);
     $this->settings['flash_video_type'] = $flash_video_type;
     $this->settings['video_type'] = $video_types;
     parent::__getConfig();
 }
开发者ID:h3len,项目名称:Project,代码行数:25,代码来源:vod_add_single_video.php

示例5: definition

 function definition()
 {
     global $DB, $CFG, $COURSE;
     $mform =& $this->_form;
     $mform->addElement('textarea', 'querysql', get_string('querysql', 'block_configurable_reports'), 'rows="35" cols="80"');
     $mform->addRule('querysql', get_string('required'), 'required', null, 'client');
     $mform->setType('querysql', PARAM_RAW);
     $mform->addElement('hidden', 'courseid', $COURSE->id);
     $mform->setType('courseid', PARAM_INT);
     $this->add_action_buttons();
     $mform->addElement('static', 'note', '', get_string('listofsqlreports', 'block_configurable_reports'));
     if ($userandrepo = get_config('block_configurable_reports', 'sharedsqlrepository')) {
         $c = new curl();
         $res = $c->get("https://api.github.com/repos/{$userandrepo}/contents/");
         $res = json_decode($res);
         if (is_array($res)) {
             $reportcategories = array(get_string('choose'));
             foreach ($res as $item) {
                 if ($item->type == 'dir') {
                     $reportcategories[$item->path] = $item->path;
                 }
             }
             $mform->addElement('select', 'reportcategories', get_string('reportcategories', 'block_configurable_reports'), $reportcategories, array('onchange' => 'M.block_configurable_reports.onchange_reportcategories(this,"' . sesskey() . '")'));
             $mform->addElement('select', 'reportsincategory', get_string('reportsincategory', 'block_configurable_reports'), $reportcategories, array('onchange' => 'M.block_configurable_reports.onchange_reportsincategory(this,"' . sesskey() . '")'));
             $mform->addElement('textarea', 'remotequerysql', get_string('remotequerysql', 'block_configurable_reports'), 'rows="15" cols="90"');
         }
     }
     //$this->add_action_buttons();
 }
开发者ID:adonm,项目名称:learning,代码行数:29,代码来源:form.php

示例6: getTitle

function getTitle($url)
{
    include '../includes/curl.php';
    $newc = new curl();
    $fd = $newc->getFile($url);
    if ($fd) {
        // Get title from title tag
        preg_match_all('/<title>(.*)<\\/title>/si', $fd, $matches);
        $title = $matches[1][0];
        // Get encoding from charset attribute
        preg_match_all('/<meta.*charset=([^;"]*)">/i', $fd, $matches);
        $encoding = strtoupper($matches[1][0]);
        // Convert to UTF-8 from the original encoding
        $title = @mb_convert_encoding($title, 'UTF-8', $encoding);
        if (strlen($title) > 0) {
            return $title;
        } else {
            // No title, so return filename
            $uriparts = explode('/', $url);
            $filename = end($uriparts);
            unset($uriparts);
            return $filename;
        }
    } else {
        return false;
    }
}
开发者ID:noikiy,项目名称:owaspbwa,代码行数:27,代码来源:booktitle.php

示例7: getVideoDownLoadUrl

 public function getVideoDownLoadUrl()
 {
     $content = file_get_contents($this->url);
     preg_match('#movieDescription=\'([^\']+)\'#', $content, $result);
     if (!($title = $result[1])) {
         preg_match("#<title>(.+)</title>#", $content, $result);
         $title = $result[1];
     }
     $title = iconv('gb2312//ignore', 'utf-8', $title);
     $this->title = $title;
     preg_match('#<source src="([^"]+)#', $content, $src) or preg_match('#<source type="[^"]+" src="([^"]+)"#', $content, $src);
     $videoSrc = $src[1] ? $src[1] : '';
     if ($videoSrc) {
         preg_match('#(.+)-mobile.mp4#', $videoSrc, $sdUrls);
         $sdUrl = $sdUrls[1] . '.flv';
         $hdUrl = preg_replace('#SD#', 'HD', $sdUrl);
         $curl = new curl();
         $sdHeader = $curl->curlGet302($sdUrl);
         $hdHeader = $curl->curlGet302($hdUrl);
         $sdSize = $curl->getSize($sdHeader);
         $hdSize = $curl->getSize($hdHeader);
         if ($sdSize > $hdSize) {
             $url = $sdUrl;
         } else {
             $url = $hdUrl;
         }
         $this->ext = 'flv';
     } else {
         preg_match('#["\'](.+)-list.m3u8["\']#', $content, $urls) || preg_match('#["\'](.+).m3u8["\']#', $content, $urls);
         $url = $urls[1] . '.mp4';
         $this->ext = 'mp4';
     }
     return $url;
 }
开发者ID:sunyymq,项目名称:php-videos,代码行数:34,代码来源:w163.php

示例8: get_listing

 /**
  * @param mixed $path
  * @param string $search
  * @return array
  */
 public function get_listing($path = '', $page = '')
 {
     global $CFG, $OUTPUT;
     $ret = array();
     $curl = new curl();
     $msg = $curl->head($this->file_url);
     $info = $curl->get_info();
     if ($info['http_code'] != 200) {
         $ret['e'] = $msg;
     } else {
         $ret['list'] = array();
         $ret['nosearch'] = true;
         $ret['nologin'] = true;
         $filename = $this->guess_filename($info['url'], $info['content_type']);
         if (strstr($info['content_type'], 'text/html') || empty($info['content_type'])) {
             // analysis this web page, general file list
             $ret['list'] = array();
             $content = $curl->get($info['url']);
             $this->analyse_page($info['url'], $content, $ret);
         } else {
             // download this file
             $ret['list'][] = array('title' => $filename, 'source' => $this->file_url, 'thumbnail' => $OUTPUT->old_icon_url(file_extension_icon($filename, 32)));
         }
     }
     return $ret;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:repository.class.php

示例9: getPublicKeyFromServer

 function getPublicKeyFromServer($server, $email)
 {
     /* refactor to 
     		$command = "gpg --keyserver ".escapeshellarg($server)." --search-keys ".escapeshellarg($email)."";
     		echo "$command\n\n";
     		
     		//execute the gnupg command
     		exec($command, $result);
     		*/
     $curl = new curl();
     // get Fingerprint
     $data = $curl->get("http://" . $server . ":11371/pks/lookup?search=" . urlencode($email) . "&op=index&fingerprint=on&exact=on");
     $data = $data['FILE'];
     preg_match_all("/<pre>([\\s\\S]*?)<\\/pre>/", $data, $matches);
     //$pub = $matches[1][1];
     preg_match_all("/<a href=\"(.*?)\">(\\w*)<\\/a>/", $matches[1][1], $matches);
     $url = $matches[1][0];
     $keyID = $matches[2][0];
     // get Public Key
     $data = $curl->get("http://" . $server . ":11371" . $url);
     $data = $data['FILE'];
     preg_match_all("/<pre>([\\s\\S]*?)<\\/pre>/", $data, $matches);
     $pub_key = trim($matches[1][0]);
     return array("keyID" => $keyID, "public_key" => $pub_key);
 }
开发者ID:baki250,项目名称:angular-io-app,代码行数:25,代码来源:class.pgp.php

示例10: post

 function post()
 {
     $service_url = 'http://www.andreseloysv.com/epg/response.php';
     $curl = curl_init($service_url);
     $curl_post_data = array('firstName' => $this->firstName, 'lastName' => $this->lastName, 'creditCardNumber' => $this->creditCardNumber, 'ccv' => $this->ccv, 'expiration_month' => $this->expiration_month, 'expiration_year' => $this->expiration_year, 'amount' => $this->amount);
     $sender = new curl($service_url, $curl_post_data);
     $result = $sender->post();
     return $result;
 }
开发者ID:andreseloysv,项目名称:epg,代码行数:9,代码来源:sendPayment.php

示例11: query

 public function query($data)
 {
     global $CFG;
     require_once $CFG->libdir . '/filelib.php';
     $c = new curl();
     $options = array('returntransfer' => true);
     $result = $c->post($this->_gatewayURL, $data, $options);
     return $result;
 }
开发者ID:Regaez,项目名称:moodle-local_moodec,代码行数:9,代码来源:gateway_dps.php

示例12: add_bookmark

function add_bookmark($uname, $title, $folderid, $url, $description, $tags = "", $newPublic = false, $date = NULL)
{
    $resultArr = array();
    $resultArr['success'] = false;
    include 'conn.php';
    require_once dirname(__FILE__) . '/protection.php';
    if ($date != "") {
        $date = "'{$date}'";
    } else {
        $date = "now()";
    }
    // Cut data to respect maximum length
    if (!empty($title)) {
        $title = substr($title, 0, 100);
    }
    if (!empty($description)) {
        $description = substr($description, 0, 150);
    }
    //$Query = sprintf("INSERT INTO " . TABLE_PREFIX . "favourites (Name , Title , FolderID , Url , Description, ADD_DATE) " . "values('" . $uname . "', %s,'" . $folderid . "', %s, %s, $date) ", quote_smart($title), quote_smart($url), quote_smart($description));
    $Query = "INSERT INTO " . TABLE_PREFIX . "favourites (Name , Title , FolderID , Url , Description, ADD_DATE) values(?, ?, ?, ?, ?, {$date})";
    $sth = $dblink->prepare($Query);
    $dataBookmark = array($uname, $title, $folderid, $url, $description);
    $AffectedRows = $sth->execute($dataBookmark);
    $rec_id = $dblink->lastInsertID(TABLE_PREFIX . "favourites", 'ID');
    if (PEAR::isError($AffectedRows)) {
        $resultArr['success'] = true;
        //echo 'ERROR: '. $AffectedRows->getMessage(). ' :: ' . $AffectedRows->getUserInfo();
    } else {
        $resultArr['success'] = true;
        $tags = trim($tags);
        if (TAGS && $tags != "") {
            require_once dirname(__FILE__) . '/tags_functions.php';
            //Remove any commas, dots, quotes, plus signs since the user might use commas to seperate tags rather than spaces
            $toRemove = array('"', "'", ",", "+");
            $tags = str_replace($toRemove, "", $tags);
            $tags = filter($tags);
            if ($tags != null && $newPublic) {
                // cut tags if too long > 150 chars
                $tags = substr($tags, 0, 150);
                //Add the tags
                addTags($tags);
                //Store the tags with the bookmark
                storeTags($rec_id, $tags);
            }
            if (USE_SCREENSHOT && CURL_AVAILABLE) {
                require_once dirname(__FILE__) . '/curl.php';
                $newc = new curl();
                $urlScreenshot = sprintf(SCREENSHOT_URL, $url);
                //echo $urlScreenshot;
                $fd = $newc->getFile($urlScreenshot);
            }
        }
    }
    return $resultArr;
}
开发者ID:noikiy,项目名称:owaspbwa,代码行数:55,代码来源:bookmarks.php

示例13: get_water_config

 public function get_water_config()
 {
     global $gGlobalConfig;
     $curl = new curl($gGlobalConfig['App_material']['host'], $gGlobalConfig['App_material']['dir']);
     $curl->setSubmitType('get');
     $curl->initPostData();
     $curl->addRequestData('a', 'get_water_config');
     $ret = $curl->request('water.php');
     $this->addItem($ret[0]);
     $this->output();
 }
开发者ID:h3len,项目名称:Project,代码行数:11,代码来源:tuji_get_name.php

示例14: column_node

 public function column_node()
 {
     $curl = new curl($this->settings['App_publishcontent']['host'], $this->settings['App_publishcontent']['dir'] . 'admin/');
     $curl->initPostData();
     $curl->addRequestData('a', 'get_all_columns');
     $return = $curl->request('column.php');
     if (is_array($return) && !$return['ErrorCode']) {
         exit(json_encode($return));
     }
     exit($return);
 }
开发者ID:h3len,项目名称:Project,代码行数:11,代码来源:route2node.php

示例15: request

 public function request($method, $params = array())
 {
     $c = new curl();
     $r = $c->request($this->url . $this->api_key . "/" . $method, 'POST', $params);
     $j = json_decode($r, true);
     if ($j) {
         return $j;
     } else {
         return $r;
     }
 }
开发者ID:ZiTAL,项目名称:php-telebot-heroku,代码行数:11,代码来源:telegram.php


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