A simple twitter SDK to interact with Twitter api (1.1)

Overview

Twitter SDK

Build Status

Installation

composer require lyrixx/twitter-sdk

Usage

Create a twitter application then

<?php

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

use Lyrixx\Twitter\Twitter;

// You can find them at: https://dev.twitter.com/apps > your app
$consumerKey = 'xvz1evFS4wEEPTGEFPHBog';
$accessToken = '370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb';
$consumerSecret = 'kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw';
$accessTokenSecret = 'LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE';

$twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);

// Fetch yours last tweets
$response = $twitter->query('GET', 'statuses/user_timeline');
$tweets = json_decode($response->getBody(), true);

// Search some tweets
$response = $twitter->query('GET', 'search/tweets', array('q' => '#symfony2'));
$tweets = json_decode($response->getBody(), true);

// Tweet
// Works only if your application has read/write scope
try {
    $response = $twitter->query('POST', 'statuses/update');
} catch (Lyrixx\Twitter\Exception\ApiClientException $e) {
    $response = $e->getResponse();
    $errors = json_decode($response->getBody(), true); // {"errors":[{"code":170,"message":"Missing required parameter: status"}]}
}

// No exception are throwed, it just works
$response = $twitter->query('POST', 'statuses/update', array('status' => 'Playing with twitter API'));

License

This library is under the MIT license. For the full copyright and license information, please view the LICENSE file that was distributed with this source code.

You might also like...
API stubs for developing a plugin that provides a 2FA authentication factor in JobRouter®.

Authentication Factor API JobRouter® is a scalable digitisation platform which links processes, data and documents. Starting with JobRouter® 5.2, a se

This repository includes a sample project to illustrate the usage of the JobRouter® Authentication Factor API.

JR 2FA Example Plugin This repository includes a sample project to illustrate the usage of the JobRouter® Authentication Factor API. It can be used as

Un proyecto que crea una API de usuarios para registro, login y luego acceder a su información mediante autenticación con JSON Web Token

JSON WEB TOKEN CON LARAVEL 8 Prueba de autenticación de usuarios con una API creada en Laravel 8 Simple, fast routing engine. License The Laravel fram

Authentication REST-API built with Lumen PHP Framework

Authentication REST-API built with Lumen PHP Framework Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expre

Laravel passport authentication API endpoints

Basic sample code for Laravel/Passport to authenticate users via API

GoSign OneSign PHP API client

OneSign PHP API Client Reikalavimai PHP 7.4+ arba 8.0+ Patariam Nginx php-fpm Funkcijos PDF dokumentų pasirašymas; laiko žymų uždėjimas ant PDF dokume

Rest API - JWT - Symfony5

Symfony5 JWT - REST API Example Symfony5 JWT - REST API Example Built With PHP Symfony 5 PostgreSQL Getting Started This is an example of how you may

Laravel JWT-Authentication API starter kit for rapid backend prototyping.

Laravel JWT API A Laravel JWT API starter kit. Features Laravel 8 Login, register, email verification and password reset Authentication with JWT Socia

It's a Laravel 8 authentication markdown that will help you to understand and grasp all the underlying functionality for Session and API Authentication

About Auth Starter It's a Laravel 8 authentication markdown that will help you to understand and grasp all the underlying functionality for Session an

Comments
  • composer require 'lyrixx/twitter-sdk:0.1.*@dev'

    composer require 'lyrixx/twitter-sdk:0.1.*@dev'

    I use the command to complete the installation. It shows this error:

    ➜  twitter-sdk git:(master) ✗ composer require 'lyrixx/twitter-sdk:0.1.*@dev'
    ./composer.json has been updated
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - Can only install one of: lyrixx/twitter-sdk[v0.1, 0.3.x-dev].
        - Can only install one of: lyrixx/twitter-sdk[v0.1, 0.3.x-dev].
        - Installation request for lyrixx/twitter-sdk 0.1.*@dev -> satisfiable by lyrixx/twitter-sdk[v0.1].
        - Installation request for lyrixx/twitter-sdk 0.3.x-dev -> satisfiable by lyrixx/twitter-sdk[0.3.x-dev].
    
    Installation failed, reverting ./composer.json to its original content.
    

    Could you help me to figure out this problem?

    PS. Although I got this fail error, I can still use the demo read me to 'playing a tweet' with the composer update.

    Please feel free to let me know if I can do any further help, thanks!

    opened by tru2dagame 4
  • Implementing LoggerAwareInterface.

    Implementing LoggerAwareInterface.

    Thanks for writing this twitter client. I thought it would be useful to set a logger after creation, so implemented Psr\Log\LoggerAwareInterface.

    Merry Christmas!

    opened by glynnforrest 2
Owner
Grégoire Pineau
DevOps ; @symfony Core contributor
Grégoire Pineau
The first PHP Library to support OAuth for Twitter's REST API.

THIS IS AN MODIFIED VERSION OF ABRAHAMS TWITTER OAUTH CLASS The directories are structured and the class uses PHP5.3 namespaces. Api.php has a new

Ruud Kamphuis 51 Feb 11, 2021
The most popular PHP library for use with the Twitter OAuth REST API.

TwitterOAuth The most popular PHP library for Twitter's OAuth REST API. See documentation at https://twitteroauth.com. PHP versions listed as "active

Abraham Williams 4.2k Dec 23, 2022
Twitter OAuth API for PHP 5.3+

README The Wid'op OAuth library is a modern PHP 5.3+ API allowing you to easily obtain a Twitter access token. For now, it supports OAuth Web & Applic

Wid'op 8 Dec 11, 2020
Magic admin PHP SDK makes it easy to leverage Decentralized ID tokens to protect routes and restricted resources for your application.

Magic Admin PHP SDK The Magic Admin PHP SDK provides convenient ways for developers to interact with Magic API endpoints and an array of utilities to

magiclabs 17 Jun 26, 2022
via this package you can push notifications to [ Facebook , Twitter , Telegram , Linkedin ] ( Laravel )

Push To Social [ Facebook , Twitter , Telegram , Linkedin ] via this package you can push notifications to [ Facebook , Twitter , Telegram , Linkedin

Peter Tharwat 29 Nov 4, 2022
A wrapper around Spatie’s Browsershot for managing social share images (OGP, Twitter etc.)

Very short description of the package This package allows you to create dynamic social sharing images in your Laravel apps. It uses Spatie’s Browsersh

Richard Le Poidevin 4 Dec 25, 2021
Symfony bundle to publish status updates on Facebook, LinkedIn and Twitter.

Upgrading? Check the upgrade guide. What's this? This is a Symfony bundle written in PHP 7.1 that wraps martin-georgiev/social-post - an easy way for

Martin Georgiev 37 Oct 30, 2022
Rinvex Authy is a simple wrapper for @Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.

Rinvex Authy Rinvex Authy is a simple wrapper for Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest AP

Rinvex 34 Feb 14, 2022
Laravel Passport is an OAuth2 server and API authentication package that is simple and enjoyable to use

Introduction Laravel Passport is an OAuth2 server and API authentication package that is simple and enjoyable to use. Official Documentation Documenta

The Laravel Framework 3.1k Dec 31, 2022
Minimalistic token-based authorization for Laravel API endpoints.

Bearer Minimalistic token-based authorization for Laravel API endpoints. Installation You can install the package via Composer: composer require ryang

Ryan Chandler 74 Jun 17, 2022