djchen/oauth1-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

djchen/oauth1-php

Composer 安装命令:

composer require djchen/oauth1-php

包简介

A simple and easy to use OAuth1 library for PHP

README 文档

README

oauth1-php is a super simple and basic PHP library for making OAuth 1.0 requests.

###Install with Composer

{
  "require" : {
    "djchen/oauth1-php" : "dev-master"
  },
  "autoload": {
    "psr-0": {"djchen": "src"}
  }
}

###Dependecies Requires PHP 5.3+ and cURL The Unirest library is used to make HTTP requests and is included in the project.

##Usage ###Initializing

$oauth = new OAuth1(array(
        'consumerKey' => 'oauth_consumer_key',
        'consumerSecret' => 'oauth_consumer_secret',
        'token' => 'oauth_token', // optional
        'tokenSecret' => 'oauth_token_secret', // optional
        'requestTokenUrl' => 'request_token_url',
        'accessTokenUrl' => 'access_token_url',
));

###Getting a request token

$result = $oauth->requestToken('callback_url');

$result is an array with the response params => values

###Getting an access token

$result = $oauth->accessToken('oauth_token', 'oauth_token_secret', 'oauth_verifier');

$result is an array with the response params => values

###Making API calls

$response = $oauth->get($url, $params = array(), $httpHeaders = array(), $oauthParams = array());
$response = $oauth->post($url, $body = null, $httpHeaders = array(), $oauthParams = array());
$response = $oauth->put($url, $body = null, $httpHeaders = array(), $oauthParams = array());
$response = $oauth->delete($url, $body = null, $httpHeaders = array(), $oauthParams = array());

The $response is an object with these fields

$response->code; // HTTP Response Status Code
$response->headers; // HTTP Response Headers
$response->body; // Parsed response body where applicable, for example JSON responses are parsed to Objects / Associative Arrays.
$response->raw_body; // Original un-parsed response body

Debug mode can be turned on via $oauth->setDebug(true). This will log both request headers and response headers and body.

统计信息

  • 总下载量: 21.47k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-05-26