<?php
/**
* tmhOAuth
*
* An OAuth 1.0A library written in PHP.
* The library supports file uploading using multipart/form as well as general
* REST requests. OAuth authentication is sent using the an Authorization Header.
*
* @author themattharris
* @version 0.7.4
*
* 19 February 2013
*/
class tmhOAuth {
const VERSION = '0.7.4';
var $response = array();
/**
* Creates a new tmhOAuth object
*
* @param string $config, the configuration to use for this request
* @return void
*/
public function __construct($config=array()) {
$this->params = array();
$this->headers = array();
$this->auto_fixed_time = false;
$this->buffer = null;
// default configuration options
$this->config = array_merge(
array(
// leave 'user_agent' blank for default, otherwise set this to
// something that clearly identifies your app
'user_agent' => '',
// default timezone for requests
'timezone' => 'UTC',
'use_ssl' => true,
'host' => 'api.twitter.com',
'consumer_key' => '',
'consumer_secret' => '',
'user_token' => '',
'user_secret' => '',
'force_nonce' => false,
'nonce' => false, // used for checking signatures. leave as false for auto
'force_timestamp' => false,
'timestamp' => false, // used for checking signatures. leave as false for auto
// oauth signing variables that are not dynamic
'oauth_version' => '1.0',
'oauth_signature_method' => 'HMAC-SHA1',
// you probably don't want to change any of these curl values
'curl_connecttimeout' => 30,
'curl_timeout' => 10,
// for security this should always be set to 2.
'curl_ssl_verifyhost' => 2,
// for security this should always be set to true.
'curl_ssl_verifypeer' => true,
// you can get the latest cacert.pem from here http://curl.haxx.se/ca/cacert.pem
'curl_cainfo' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'cacert.pem',
'curl_capath' => dirname(__FILE__),
'curl_followlocation' => false, // whether to follow redirects or not
// support for proxy servers
'curl_proxy' => false, // really you don't want to use this if you are using streaming
'curl_proxyuserpwd' => false, // format username:password for proxy, if required
'curl_encoding' => '', // leave blank for all supported formats, else use gzip, deflate, identity
// streaming API
'is_streaming' => false,
'streaming_eol' => "\r\n",
'streaming_metrics_interval' => 60,
// header or querystring. You should always use header!
// this is just to help me debug other developers implementations
'as_header' => true,
'debug' => false,
),
$config
);
$this->set_user_agent();
date_default_timezone_set($this->config['timezone']);
}
/**
* Sets the useragent for PHP to use
* If '$this->config['user_agent']' already has a value it is used instead of one
* being generated.
*
* @return void value is stored to the config array class variable
*/
private function set_user_agent() {
if (!empty($this->config['user_agent']))
return;
if ($this->config['curl_ssl_verifyhost'] && $this->config['curl_ssl_verifypeer']) {
$ssl = '+SSL';
} else {
$ssl = '-SSL';
}
$ua = 'tmhOAuth ' . self::VERSION . $ssl . ' - //github.com/themattharris/tmhOAuth';
$this->config['user_agent'] = $ua;
}
/**
* Generates a random OAuth nonce.
* If 'force_nonce' is true a nonce is not generated and the value in the configuration will be retained.
*
* @param string $length how many characters the nonce should be before MD5 hashing. default 12
* @param string $include_time whether to include time at the beginning of the nonce. default true
* @return void value is stored to the config array class variable
*/
private function create_nonce($length=12, $include_time=true) {
if ($this->config['force_nonce'] == false) {
$sequence = array_merge(range(0,9), range('A','Z'), range('a','z'));
$length = $length > count($sequence) ? count($sequence) : $length;
shuffle($sequence);
$prefix = $include_time ? microtime() : '';
$this->config['nonce'] = md5(substr($prefix . implode('', $sequence), 0, $length));
}
}
/**
* Generates a timestamp.
* If 'force_timestamp' is true a nonce is not generated and the value in the configuration will be retained.
*
* @return void value is stored to the config array class variable
*/
private function create_timestamp() {
$this->config['timestamp'] = ($this->config['force_timestamp'] == false ? time() : $this->config['timestamp']);
}
/**
* Encodes the string or array passed in a way compatible with OAuth.
* If an array is passed each array value will will be encoded.
*
* @param mixed $data the scalar or array to encode
* @return $data encoded in a way compatible with OAuth
*/
private function safe_encode($data) {
if (is_array($data)) {
return array_map(array($this, 'safe_encode'), $data);
} else if (is_scalar($data)) {
return str_ireplace(
array('+', '%7E'),
array(' ', '~'),
rawurlencode($data)
);
} else {
return '';
}
}
/**
* Decodes the string or array from it's URL encoded form
* If an array is passed each array value will will be decoded.
*
* @param mixed $data the scalar or array to decode
* @return string $data decoded from the URL encoded form
*/
private function safe_decode($data) {
if (is_array($data)) {
return array_map(array($this, 'safe_decode'), $data);
} else if (is_scalar($data)) {
return rawurldecode($data);
} else {
return '';
}
}
/**
* Returns an array of the standard OAuth parameters.
*
* @return array all required OAuth parameters, safely encoded
*/
private function get_defaults() {
$defaults = array(
'oauth_version' => $this->config['oauth_version'],
'oauth_nonce' => $this->config['nonce'],
'oauth_timestamp' => $this->config['timestamp'],
'oauth_consumer_key' => $this->config['consumer_key'],
'oauth_signature_method' => $this->config['oauth_signature_method'],
);
// include the user token if it exists
if ( $this->config['user_token'] )
$defaults['oauth_token'] = $this->config['user_token'];
// safely encode
foreach ($defaults as $k => $v) {
$_defaults[$this->safe_encode($k)] = $this->safe_encode($v);
}
return $_defaults;
}
/**
* Extracts and decodes OAuth parameters from the passed string
*
* @param string $body the response body from an OAuth flow method
* @return array the response body safely decoded to an array of key => values
*/
public function extract_params($body) {
$kvs = explode('&', $body);
$decoded = array();
foreach ($kvs as $kv) {
$kv = explode('=', $kv, 2);
$kv[0] = $this->safe_decode($kv[0]);
$kv[1] = $this->safe_decode($kv[1]);
$decoded[$kv[0]] = $kv[1];
}
return $decoded;
}
/**
* Prepares the HTTP method for use in the base string by converting it to
* uppercase.
*
* @param string $method an HTTP method such as GET or POST
* @return void value is stored to the class variable 'method'
*/
private function prepare_method($method) {
$this->method = strtoupper($method
没有合适的资源?快使用搜索试试~ 我知道了~
响应式的单页面网站模板
共407个文件
svg:245个
js:47个
png:32个
5星 · 超过95%的资源 需积分: 10 60 下载量 166 浏览量
2014-01-24
12:33:24
上传
评论
收藏 2.98MB ZIP 举报
温馨提示
响应式的单页面网站模板,适应现在大部分浏览器
资源推荐
资源详情
资源评论
收起资源包目录
响应式的单页面网站模板 (407个子文件)
bootstrap.min.css 103KB
main.css 25KB
fonts.css 19KB
style.css 19KB
bootstrap-responsive.min.css 16KB
style.css 12KB
shortcodes.css 11KB
shCoreEclipse.css 9KB
shCoreDjango.css 9KB
shCoreFadeToGrey.css 9KB
shCoreDefault.css 9KB
shCoreMidnight.css 8KB
shCoreRDark.css 8KB
shCoreEmacs.css 8KB
shCoreMDUltra.css 8KB
responsive.css 6KB
shCore.css 6KB
jquery.fancybox.css 5KB
jquery.mCustomScrollbar.css 5KB
supersized.shutter.css 5KB
shThemeEclipse.css 3KB
shThemeDefault.css 3KB
shThemeDjango.css 3KB
shThemeFadeToGrey.css 3KB
shThemeMidnight.css 3KB
shThemeRDark.css 3KB
shThemeEmacs.css 3KB
shThemeMDUltra.css 3KB
supersized.css 1KB
Thumbs.db 13KB
.DS_Store 15KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
Icons.eot 32KB
Icons.eot 32KB
fancybox_loading.gif 4KB
progress.gif 3KB
blank.gif 43B
index.html 99KB
index.html 69KB
shortcodes.html 48KB
index.html 24KB
image01.jpg 18KB
image03.jpg 18KB
image02.jpg 18KB
image04.jpg 18KB
image-02-full.jpg 13KB
image-06-full.jpg 13KB
image-01-full.jpg 13KB
image-05-full.jpg 13KB
image-04-full.jpg 13KB
image-03-full.jpg 13KB
image-07-full.jpg 13KB
image-06.jpg 6KB
image-08.jpg 6KB
image-04.jpg 6KB
image-03.jpg 6KB
image-09.jpg 6KB
image-05.jpg 6KB
image-07.jpg 6KB
image-02.jpg 6KB
image-01.jpg 6KB
profile-03.jpg 3KB
profile-01.jpg 3KB
profile-02.jpg 3KB
jquery-ui-1.8.23.custom.min.js 200KB
jquery.js 91KB
jquery.mCustomScrollbar.js 33KB
bootstrap.min.js 28KB
supersized.3.2.7.min.js 25KB
jquery.fancybox.pack.js 22KB
waypoints.js 16KB
shCore.js 16KB
jquery.isotope.js 16KB
modernizr.js 15KB
modernizr.js 14KB
plugins.js 14KB
jquery.tweet.js 14KB
main.js 12KB
lte-ie7.js 10KB
shBrushColdFusion.js 8KB
shBrushAppleScript.js 8KB
shBrushSass.js 6KB
shBrushCss.js 6KB
shBrushCpp.js 5KB
shBrushPhp.js 5KB
jquery.fancybox-media.js 5KB
shBrushPowerShell.js 4KB
placeholder.js 4KB
shBrushPerl.js 3KB
shBrushSql.js 3KB
shBrushGroovy.js 3KB
shBrushBash.js 3KB
共 407 条
- 1
- 2
- 3
- 4
- 5
资源评论
- tc9365967782014-07-04正好能用到,十分感谢!
- 含章子2015-10-09改改还是可以用的。挺不错。
- morphy20072014-05-06收藏起来以后有机会用!
- ittraining2014-08-14很一般,不是那种滚屏的单页网站。
一根小稻草
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 什么是移动应用开发-关于移动应用开发的相关介绍
- 第二组汇报 PPT.pptx
- 什么是大数据开发-相关介绍-关于大数据开发的相关介绍
- 什么是软件测试-相关介绍-关于软件测试的相关介绍
- 前端开发-什么是前端开发-关于前端开发的一些相关介绍
- Sora AI-关于文生视频的使用场景说明
- suno AI文生视频的相关教程和介绍使用
- 什么是后端开发-关于后端开发的一些小介绍分享
- Jurassic Pack Vol. II Dinosaurs 侏罗纪包卷恐龙二号Unity游戏模型资源unitypackage
- Jurassic Pack Vol. III Dinosaurs 侏罗纪包卷恐龙三号Unity游戏模型资源unitypackag
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功