當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。