Giter Club home page Giter Club logo

twitteroauth-1's Introduction

TwitterOAuth

PHP library to communicate with Twitter OAuth API version 1.1.

  • Namespaced
  • PHP 5.3
  • PSR-2
  • OOP

Requirements

  • PHP Version >= 5.3
  • PHP cURL extension

Installation

The recommended way to install TwitterOAuth is through Composer:

{
    "require": {
        "ricardoper/twitteroauth": "dev-master"
    }
}

Example

<?php

	use TwitterOAuth\TwitterOAuth;

	date_default_timezone_set('UTC');

	require_once __DIR__ . '/vendor/autoload.php';

	/**
	 * Array with the OAuth tokens provided by Twitter when you create application
	 *
	 * output_format - Optional - Values: text|json|array|object - Default: object
	 */
    $config = array(
        'consumer_key' => '01b307acba4f54f55aafc33bb06bbbf6ca803e9a',
        'consumer_secret' => '926ca39b94e44e5bdd4a8705604b994ca64e1f72',
        'oauth_token' => 'e98c603b55646a6d22249d9b0096e9af29bafcc2',
        'oauth_token_secret' => '07cfdf42835998375e71b46d96b4488a5c659c2f',
        'output_format' => 'object'
    );

	/**
	 * Instantiate TwitterOAuth class with set tokens
	 */
	$tw = new TwitterOAuth($config);


	/**
	 * Returns a collection of the most recent Tweets posted by the user
	 * https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline
	 */
	$params = array(
	    'screen_name' => 'ricard0per',
	    'count' => 5,
	    'exclude_replies' => true
	);

	/**
	 * Send a GET call with set parameters
	 */
	$response = $tw->get('statuses/user_timeline', $params);

	var_dump($response);


	/**
	 * Creates a new list for the authenticated user
	 * https://dev.twitter.com/docs/api/1.1/post/lists/create
	 */
	$params = array(
	    'name' => 'TwOAuth',
	    'mode' => 'private',
	    'description' => 'Test List',
	);

	/**
	 * Send a POST call with set parameters
	 */
	$response = $tw->post('lists/create', $params);

	var_dump($response);

License

Released under the MIT License.

twitteroauth-1's People

Contributors

ricardoper avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.