本文整理汇总了PHP中http::get方法的典型用法代码示例。如果您正苦于以下问题:PHP http::get方法的具体用法?PHP http::get怎么用?PHP http::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http
的用法示例。
在下文中一共展示了http::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
}
示例2: 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();
}
}
示例3: 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;
}
示例4: __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>');
}
}
示例5: 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;
}
示例6: 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);
}
示例7: ticket
/**
* Get jsticket.
*
* @return string
*/
public function ticket()
{
$key = self::TICKET_CACHE_PREFIX . $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'] - 500);
return $result['ticket'];
});
}
示例8: 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'];
});
}
示例9: getOpenId
/**
* 获取openid
* @return mixed
* @throws Exception
*/
public function getOpenId()
{
if ($this->openid) {
return $this->openid;
}
$data = http::get($this->apiBase . 'oauth2.0/me', array('access_token' => $this->token));
$data = json_decode(trim(substr($data, 9), " );\n"), true);
if (isset($data['openid'])) {
$this->openid = $data['openid'];
return $data['openid'];
} else {
throw new Exception("获取用户openid出错:{$data['error_description']}");
}
}
示例10: request
public function request($arg)
{
if ($err = parent::request($arg)) {
return $err;
}
$code = $_REQUEST['code'];
$resp = http::post('https://oauth.yandex.ru/token', array('code' => $code, 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'grant_type' => 'authorization_code'));
if ($resp) {
$tokens = json_decode($resp);
if ($r = http::get('https://login.yandex.ru/info?format=json&oauth_token=' . $tokens->access_token)) {
$info = json_decode($r);
return $this->adduser(array('service' => $this->name, 'uid' => $info->id, 'email' => isset($info->default_email) ? $info->default_email : $info->emails[0], 'name' => isset($info->real_name) ? $info->real_name : $info->display_name), $info);
}
}
return $this->errorauth();
}
示例11: request
public function request($arg)
{
if ($err = parent::request($arg)) {
return $err;
}
$code = $_REQUEST['code'];
$resp = http::post('https://accounts.google.com/o/oauth2/token', array('code' => $code, 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'redirect_uri' => litepublisher::$site->url . $this->url, 'grant_type' => 'authorization_code'));
if ($resp) {
$tokens = json_decode($resp);
if ($r = http::get('https://www.googleapis.com/oauth2/v1/userinfo?access_token=' . $tokens->access_token)) {
$info = json_decode($r);
return $this->adduser(array('service' => $this->name, 'email' => isset($info->email) ? $info->email : '', 'name' => $info->name, 'website' => isset($info->link) ? $info->link : ''), $info);
}
}
return $this->errorauth();
}
示例12: request
public function request($arg)
{
if ($err = parent::request($arg)) {
return $err;
}
$code = $_REQUEST['code'];
$resp = http::get('https://graph.facebook.com/oauth/access_token?' . http_build_query(array('code' => $code, 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'redirect_uri' => litepublisher::$site->url . $this->url)));
if ($resp) {
$params = null;
parse_str($resp, $params);
if ($r = http::get('https://graph.facebook.com/me?access_token=' . $params['access_token'])) {
$info = json_decode($r);
return $this->adduser(array('service' => $this->name, 'uid' => isset($info->id) ? $info->id : '', 'email' => isset($info->email) ? $info->email : '', 'name' => $info->name, 'website' => isset($info->link) ? $info->link : ''), $info);
}
}
return $this->errorauth();
}
示例13: request
public function request($arg)
{
if ($err = parent::request($arg)) {
return $err;
}
$code = $_REQUEST['code'];
$resp = http::post('https://oauth.vk.com/access_token', array('code' => $code, 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'redirect_uri' => litepublisher::$site->url . $this->url));
if ($resp) {
$tokens = json_decode($resp);
if ($r = http::get('https://api.vk.com/method/getProfiles?uids=' . $tokens->user_id . '&access_token=' . $tokens->access_token)) {
$js = json_decode($r);
$info = $js->response[0];
return $this->adduser(array('service' => $this->name, 'uid' => $info->uid, 'name' => $info->first_name . ' ' . $info->last_name, 'website' => 'http://vk.com/id' . $info->uid), $info);
}
}
return $this->errorauth();
}
示例14: request
public function request($arg)
{
if ($err = parent::request($arg)) {
return $err;
}
$code = $_REQUEST['code'];
$resp = http::post('https://connect.mail.ru/oauth/token', array('code' => $code, 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'redirect_uri' => litepublisher::$site->url . $this->url, 'grant_type' => 'authorization_code'));
if ($resp) {
$tokens = json_decode($resp);
$params = array('method' => 'users.getInfo', 'app_id' => $this->client_id, 'session_key' => $tokens->access_token, 'uids' => $tokens->x_mailru_vid, 'secure' => '1', 'format' => 'json');
ksort($params);
$params['sig'] = $this->sign($params, $this->client_secret);
if ($r = http::get('http://www.appsmail.ru/platform/api?' . http_build_query($params))) {
$js = json_decode($r);
$info = $js[0];
return $this->adduser(array('uid' => $info->uid, 'email' => isset($info->email) ? $info->email : '', 'name' => $info->nick, 'website' => isset($info->link) ? $info->link : ''), $info);
}
}
return $this->errorauth();
}
示例15: query
function query($args, $document)
{
$this->validate($args);
$xml = new xml();
$get = [];
foreach ($this->get as $name => $value) {
$get[$name] = vars::apply_assoc($value, $args);
}
switch ($this->method) {
case 'get':
return self::to_xml(http::get($this->url, $get, $this->datasource['username'], $this->datasource['password']));
case 'post':
$post = [];
foreach ($this->post as $name => $value) {
$post[$name] = vars::apply_assoc($value, $args);
}
return self::to_xml(http::post($this->url, $post, $get, $this->datasource['username'], $this->datasource['password']));
default:
runtime_error('Unknown HTTP procedure method: ' . $this->method);
}
}