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


PHP http类代码示例

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


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

示例1: getQuoteData

/** Function to get company quotes from external site
 * @param $var -- var:: Type string(company trickersymbol)
 * @returns $quote_data -- quote_data:: Type string array
 *
 */
function getQuoteData($var)
{
    $url = "http://finance.yahoo.com/q?s=" . $var;
    $h = new http();
    $h->dir = "class_http_dir/";
    if (!$h->fetch($url, 2)) {
        echo "<h2>There is a problem with the http request!</h2>";
        echo $h->log;
        exit;
    }
    $res_arr = array();
    $quote_data = http::table_into_array($h->body, 'Delayed quote data', 0, null);
    if (is_array($quote_data)) {
        array_shift($quote_data);
        array_shift($quote_data);
        if ($quote_data[0][0] != 'Last Trade:') {
            array_shift($quote_data);
        }
    } else {
        die;
    }
    for ($i = 0; $i < 16; $i++) {
        if ($quote_data != '') {
            $res_arr[] = $quote_data[$i];
        }
    }
    return $res_arr;
}
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:33,代码来源:getCompanyProfile.php

示例2: __construct

 public function __construct($id)
 {
     $server = Servers::model()->findByPK($id);
     $http = new http();
     $http->setTimeout(10);
     $this->moment = new moment($http, array('server_ip' => $server->ip, 'server_port' => $server->s_port, 'web_port' => $server->w_port));
 }
开发者ID:mrtos,项目名称:OpenNVR,代码行数:7,代码来源:momentManager.php

示例3: act_message

 static function act_message()
 {
     if (post('message_submit', 'isset')) {
         //检查验证码
         $check_code = post('code', 'post');
         if ($check_code != session('message_code', true)) {
             http::json(array('error' => 2, 'info' => 'check_code error'));
         }
         //接收、过滤数据
         $data['user_name'] = post('name', 'title');
         $data['tel'] = post('contact_tel', 'number');
         $data['phone'] = post('contact_phone', 'account');
         $data['email'] = post('email', 'account');
         $data['message'] = post('message_content', 'info');
         //验证数据
         $data['tel'] = safe::reg($data['tel'], 'tel') ? $data['tel'] : null;
         $data['phone'] = safe::reg($data['phone'], 'phone') ? $data['phone'] : null;
         $data['email'] = safe::reg($data['email'], 'email') ? $data['email'] : null;
         if ($data['message']) {
             $add_result = db::add('message', $data);
             //将数据写入留言表
             if ($add_result) {
                 http::json(array('error' => 0, 'info' => 'add message succeed'));
             }
         }
     }
     //以json格式返回给浏览器
     http::json(array('error' => 1, 'info' => 'add message failed'));
 }
开发者ID:art-youth,项目名称:framework,代码行数:29,代码来源:a_index.php

示例4: processform

 public function processform()
 {
     if (!isset($_POST['contactvalue'])) {
         return '';
     }
     $time = substr($_POST['contactvalue'], strlen('_contactform'));
     if (time() > $time) {
         return $this->errmesg;
     }
     $email = trim($_POST['email']);
     if (!tcontentfilter::ValidateEmail($email)) {
         return sprintf('<p><strong>%s</strong></p>', tlocal::get('comment', 'invalidemail'));
     }
     $url = trim($_POST['site']);
     if (empty($url) || strbegin($url, litepublisher::$site->url)) {
         return $this->errmesg;
     }
     if ($s = http::get($url)) {
         if (!strpos($s, '<meta name="generator" content="Lite Publisher')) {
             return $this->errmesg;
         }
     } else {
         return $this->errmesg;
     }
     $content = trim($_POST['content']);
     if (strlen($content) <= 15) {
         return sprintf('<p><strong>%s</strong></p>', tlocal::get('comment', 'emptycontent'));
     }
     $content = "{$url}\n" . $_POST['sitetitle'] . "\n\n" . $content;
     tmailer::sendmail('', $email, '', litepublisher::$options->email, $this->subject, $content);
     return $this->success;
 }
开发者ID:laiello,项目名称:litepublisher,代码行数:32,代码来源:contactsite.class.php

示例5: eqphp_autoload

function eqphp_autoload($class)
{
    if (isset($_SERVER['REQUEST_URI'])) {
        $root = current(explode('/', trim($_SERVER['REQUEST_URI'], '/')));
    }
    //optimize: $config save memcache or redis
    $group = config('group.list');
    $path = isset($root) && is_array($group) && in_array($root, $group) ? $root . '/' : '';
    $module = array('a' => $path . 'action', 'm' => $path . 'model', 'p' => $path . 'plugin', 's' => 'server');
    $prefix = substr($class, 0, strpos($class, '_'));
    $dir_name = in_array($prefix, array('a', 'm', 's', 'p')) ? $module[$prefix] : 'class';
    $execute_file = $dir_name . '/' . $class . '.php';
    if (file_exists($execute_file)) {
        return include PATH_ROOT . $execute_file;
    }
    //通用加载
    if (config('state.common_load') && in_array($prefix, array('a', 'm'), true)) {
        $common_option = array('a' => 'action/', 'm' => 'model/');
        $execute_file = PATH_ROOT . $common_option[$prefix] . $class . '.php';
        if (file_exists($execute_file)) {
            return include $execute_file;
        }
    }
    //贪婪加载
    if (config('state.greedy_load')) {
        $execute_file = file::search(PATH_ROOT . $dir_name, $class, $file_list, true);
        if ($execute_file) {
            return include $execute_file;
        }
    }
    if ($prefix === 'a') {
        logger::notice('class [' . $class . '] not found');
        http::send(404);
    }
}
开发者ID:lianren,项目名称:framework,代码行数:35,代码来源:common.php

示例6: parse

 public static function parse($url)
 {
     if ($s = http::get($url)) {
         $backuper = tbackuper::i();
         $archtype = $backuper->getarchtype($url);
         if ($files = $backuper->unpack($s, $archtype)) {
             list($filename, $content) = each($files);
             if ($about = self::getabout($files)) {
                 $item = new tdownloaditem();
                 $item->type = strbegin($filename, 'plugins/') ? 'plugin' : 'theme';
                 $item->title = $about['name'];
                 $item->downloadurl = $url;
                 $item->authorurl = $about['url'];
                 $item->authorname = $about['author'];
                 $item->rawcontent = $about['description'];
                 $item->version = $about['version'];
                 $item->tagnames = empty($about['tags']) ? '' : trim($about['tags']);
                 if ($screenshot = self::getfile($files, 'screenshot.png')) {
                     $media = tmediaparser::i();
                     $idscreenshot = $media->uploadthumbnail($about['name'] . '.png', $screenshot);
                     $item->files = array($idscreenshot);
                 }
                 return $item;
             }
         }
     }
     return false;
 }
开发者ID:laiello,项目名称:litepublisher,代码行数:28,代码来源:about.parser.class.php

示例7: processform

 public function processform()
 {
     $plugin = tsourcefiles::i();
     if (isset($_POST['download'])) {
         set_time_limit(300);
         $version = litepublisher::$options->version;
         if (!(($s = http::get("http://litepublisher.googlecode.com/files/litepublisher.{$version}.tar.gz")) || ($s = http::get("http://litepublisher.com/download/litepublisher.{$version}.tar.gz")))) {
             return 'Error download';
         }
         tbackuper::include_tar();
         $tar = new tar();
         $tar->loadfromstring($s);
         if (!is_array($tar->files)) {
             unset($tar);
             return 'Invalid file archive';
         }
         tfiler::delete($plugin->root, true, false);
         foreach ($tar->files as $item) {
             $filename = $plugin->root . $item['name'];
             $dir = dirname($filename);
             if (!is_dir($dir)) {
                 $this->mkdir($dir);
             }
             file_put_contents($filename, $item['file']);
             @chmod($filename, 0666);
         }
         unset($tar);
         $plugin->reread();
     } elseif (isset($_POST['reread'])) {
         $plugin->reread();
     } else {
         $plugin->root = $_POST['root'];
         $plugin->save();
     }
 }
开发者ID:laiello,项目名称:litepublisher,代码行数:35,代码来源:admin.sourcefiles.class.php

示例8: fileadded

 public function fileadded($id)
 {
     $files = tfiles::i();
     $item = $files->getitem($id);
     if ('image' != $item['media']) {
         return;
     }
     $fileurl = $files->geturl($id);
     if ($s = http::get('http://www.smushit.com/ysmush.it/ws.php?img=' . urlencode($fileurl))) {
         $json = json_decode($s);
         if (isset($json->error) || -1 === (int) $json->dest_size || !$json->dest) {
             return;
         }
         $div = $item['size'] - (int) $json->dest_size;
         if ($div / ($item['size'] / 100) < 3) {
             return;
         }
         $dest = urldecode($json->dest);
         if (!strbegin($dest, 'http')) {
             $dest = 'http://www.smushit.com/' . $dest;
         }
         if ($content = http::get($dest)) {
             return $files->setcontent($id, $content);
         }
     }
 }
开发者ID:laiello,项目名称:litepublisher,代码行数:26,代码来源:smushit.plugin.php

示例9: __call

 public function __call($method, $params = array())
 {
     $params = $params['0'];
     $params['action'] = $method;
     $params['appid'] = $this->appid;
     $params['format'] = 'json';
     $params['datetime'] = $_SERVER['REQUEST_TIME'];
     $params['sign'] = $this->sign($params);
     //自动重试5次 防止失败!
     for ($i = 0; $i < 5; $i++) {
         $data = json_decode(http::get($this->apiurl, $params), true);
         if (is_array($data) && $data['status'] != 0) {
             break;
         }
     }
     if (is_array($data)) {
         if ($data['status'] == 1) {
             return $data['data'];
         } else {
             exit('采集错误!原因:' . $data['msg'] . ' 参数:<pre>' . var_export($params, true) . '</pre>');
         }
     } else {
         exit('采集错误!方法' . $method . ' 参数:<pre>' . var_export($params, true) . '</pre>');
     }
 }
开发者ID:oohook,项目名称:PTFrameWork,代码行数:25,代码来源:apiclient.php

示例10: index

 function index()
 {
     //验证权限,跳转提示页面
     if (!in_array(parent::visite_access, $this->admin_access)) {
         http::skip('message/login/forbid');
     }
     //接收请求参数
     $category = rq(2);
     //类型(1,已读/0,未读/全部)
     $page = rq(3, 1);
     //页码
     //获取删除和回复权限
     $del_access = in_array(parent::del_access, $this->admin_access);
     $reply_access = in_array(parent::reply_access, $this->admin_access);
     //调用查询模型
     $message = self::message_model($category, $page, 10);
     //处理分页导航
     $page_url = dc_url . 'manage/' . $category . '/';
     $page_nav = s_page::mark($page_url, $message['info'][0], $page, 3);
     //视图赋值
     $tpl = smarty('admin');
     $head['frame'] = '_self';
     $head['title'] = '留言管理_EQPHP案例留言本';
     $tpl->assign('head', $head);
     $tpl->assign('del_access', $del_access);
     $tpl->assign('reply_access', $reply_access);
     $tpl->assign('rs_count', $message['num']);
     $tpl->assign('message', $message['info'][1]);
     $tpl->assign('page_nav', $page_nav);
     //渲染视图模板
     $tpl->display('message/manage');
 }
开发者ID:art-youth,项目名称:framework,代码行数:32,代码来源:a_manage.php

示例11: eqphp_autoload

function eqphp_autoload($lib_name)
{
    $server_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
    $group = explode(',', config('group|info'));
    $rq_url = explode('/', trim($server_uri, '/'));
    $dir_first = array('a' => 'action', 'm' => 'model');
    $dir_second = array('a' => $rq_url[0] . '/action', 'm' => $rq_url[0] . '/model');
    $dir_arr = in_array($rq_url[0], $group) ? $dir_second : $dir_first;
    $dir_arr = array_merge($dir_arr, array('s' => 'server', 'p' => 'plugin'));
    $prefix = substr($lib_name, 0, strpos($lib_name, '_'));
    $dir_name = in_array($prefix, array_keys($dir_arr)) ? $dir_arr[$prefix] : 'class';
    $execute_file = $dir_name . '/' . $lib_name . '.php';
    if (strtolower($lib_name) == 'smarty') {
        $execute_file = 'data/smarty/Smarty.class.php';
    }
    if (file_exists($execute_file)) {
        return include dc_root . $execute_file;
    }
    if ($prefix == 'a') {
        $tpl_file = dc_root . 'view/' . substr($lib_name, 2) . '.html';
        if (file_exists($tpl_file)) {
            exit(include $tpl_file);
        }
        if ($execute_file != 'action/a_.php') {
            http::send(404, 0);
            http::out('404 Not Found');
        }
    }
    if (strpos(strtolower($execute_file), 'smarty_internal_') === false) {
        echo "class [" . $lib_name . "] is error !<br>";
    }
}
开发者ID:art-youth,项目名称:framework,代码行数:32,代码来源:index.php

示例12: call

 /**
  * 组装接口调用参数 并调用接口
  *
  * @param  string $api    微博API
  * @param  array $param   调用API的额外参数
  * @param  string $method HTTP请求方法 默认为GET
  * @param  bool $multi
  * @return string json
  */
 public function call($api, $param = array(), $method = 'GET', $multi = false)
 {
     /* 腾讯QQ调用公共参数 */
     $params = array('access_token' => $this->token);
     $params = array_merge($params, $param);
     $data = http::get($this->apiBase . $api, $params);
     return json_decode($data, true);
 }
开发者ID:oohook,项目名称:PTFrameWork,代码行数:17,代码来源:weibo.php

示例13: desc

 public function desc($id)
 {
     ControllerTray::instance()->renderLayout = false;
     http::contentType('application/json');
     $this->data->id = $id;
     $this->data->info = new \ROM\BongUserData();
     $this->data->info->load($id . '.usr');
 }
开发者ID:neel,项目名称:bong,代码行数:8,代码来源:abstractor.php

示例14: getTicket

 /**
  * Get jsticket.
  *
  * @return string
  */
 public function getTicket()
 {
     $key = 'overtrue.wechat.jsapi_ticket.' . $this->appId;
     return $this->cache->get($key, function ($key) {
         $result = $this->http->get(self::API_TICKET);
         $this->cache->set($key, $result['ticket'], $result['expires_in'] - 100);
         return $result['ticket'];
     });
 }
开发者ID:heyjun,项目名称:wechat,代码行数:14,代码来源:SDK.php

示例15: fetch_remote_xml

function fetch_remote_xml($url, $fetcher = false)
{
    // Create a new instance of Troy Wolf's HTTP class (if a mock one
    // wasn't created during testing)
    if (!is_object($fetcher)) {
        $fetcher = new http();
    }
    // Set the path of the cache
    $fetcher->dir = dirname(__FILE__) . "/cache/";
    // Fetch the data from the URL using a GET request (that's really
    // all we need for this plugin--we're really only fetching gdata here)
    if (!$fetcher->fetch($url, 43200)) {
        return false;
    }
    // Let's return the http class object to the caller function, assuming that we
    // actually received some
    return $fetcher;
}
开发者ID:hellojwilde,项目名称:feed-stats,代码行数:18,代码来源:client.php


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