The most popular PHP library for use with the Twitter OAuth REST API.

Overview

TwitterOAuth Build Status Scrutinizer Code Quality Issues Count Latest Version Downloads this Month


The most popular PHP library for Twitter's OAuth REST API.

See documentation at https://twitteroauth.com.

PHP versions listed as "active support" or "security fixes only" are supported.

Twitter bird

Comments
  • retrieve user's email (again)

    retrieve user's email (again)

    Hi, I've done every thing with Twitter policies to have my website on Twitter's whitelist. (https://dev.twitter.com/rest/reference/get/account/verify_credentials) My app tells me it's "OK", I can get the user's email. But when I make this, I can't find any email. I did this:

    $user_infos = $twitter_conn->get("account/verify_credentials", ['include_entities' => true, 'skip_status' => true, 'include_email' => true]);
    

    Have you any suggestion to get it ? Regards

    Task 
    opened by TheExcalibur 44
  • Use clear error message on timeout

    Use clear error message on timeout

    Why Me always get this error ?

    [12-Apr-2015 23:38:35 UTC] PHP Fatal error:  Uncaught exception 'Abraham\TwitterOAuth\TwitterOAuthException' in /home/xxx/public_html/twitteroauth/src/TwitterOAuth.php:141
    Stack trace:
    #0 /home/xxx/public_html/view/callback.php(23): Abraham\TwitterOAuth\TwitterOAuth->oauth('oauth/access_to...', Array)
    #1 /home/xxx/public_html/page.php(24): require_once('/home/xxx/...')
    #2 {main}
      thrown in /home/xxx/public_html/twitteroauth/src/TwitterOAuth.php on line 141
    
    Task Misc Available 
    opened by uzanpower 35
  • Fatal error: Class 'Abraham\TwitterOAuth\Config' not found in …

    Fatal error: Class 'Abraham\TwitterOAuth\Config' not found in …

    Hi,

    I've been going through loads of previous issues here to try and see if they could help with trying to get this to work for me, but I'm stumped. Sorry, I'm not a php dev, so I'm using the manual method as described :-(

    require "twitteroauth/autoload.php"; use Abraham\TwitterOAuth\TwitterOAuth;

    The full error is:

    Fatal error: Class 'Abraham\TwitterOAuth\Config' not found in /var/www/vhosts/stagingtesting.com/subdomains/redtree.stagingtesting.com/wp-content/themes/redtree/includes/twitter/twitteroauth/src/TwitterOAuth.php on line 17

    So I'm guessing I'm having paths issues.

    It's a Wordpress site, so in footer.php I've got this:

    <?php get_template_part('includes/twitter/get-tweets'); ?>

    And it's in this get-tweets.php file that I'm requiring Twitteroauth as above. My twitteroauth directory is at the same level as this php file and the files are extracted as you described. I did a print_r on $base_dir in autoload.php and it returns this which I presume is not correct:

    /var/www/vhosts/stagingtesting.com/subdomains/redtree.stagingtesting.com/wp-content/themes/redtree/includes/twitter/twitteroauth/src//var/www/vhosts/stagingtesting.com/subdomains/redtree.stagingtesting.com/wp-content/themes/redtree/includes/twitter/twitteroauth/src/

    The path is double stacked.

    One other thing to note is that it works on my local MAMP using php 7.1.0 but not on the live site with Shared hosting PHP 7.1 CGI (7.1.6).

    Any thoughts on what's happening here? Sorry, I know you've been queried about this issue many times.

    Thanks!

    opened by petebarr 25
  • statuses/update_with_media

    statuses/update_with_media

    Hi there,

    I made uploading images work as per https://dev.twitter.com/docs/api/1/post/statuses/update_with_media

    You need to use $connection->upload() instead of $connection->post();

    opened by robhaswell 22
  • Could not connect to Twitter. Refresh the page or try again later.

    Could not connect to Twitter. Refresh the page or try again later.

    Hi abraham.. I have no problem before with the script.. it works fine last time. I used this twitter auth in my client website but now i try to use it again in my current client (Of course i registered the new app and got new code for the key and secret code). This is really strange. Because i get the error just like the title above... Everything was working very well when i try it from localhost, and my previous client nothing wrong, but this time it didnt work. My new client have his own server, using centos, 5 and he installed apache mysql and php. I believe there's nothing wrong with the code of your script. maybe there's something i have to active it from the server ?

    Waiting on 
    opened by Portnumbay 22
  • Undefined index oauth_token

    Undefined index oauth_token

    Hi, I''m getting the following error when I try to run getRequestToken();

    Message: Undefined index: oauth_token File: twitteroauth.php Line: 82

    Not sure what could be wrong, I double checked my secret and api key and it should be fine. Please let me know what I can do to help debug this.

    opened by jahvi 19
  • Can't connect to Twitter

    Can't connect to Twitter

    I have been struggling with the Twitter API and OAuth and tried using this plugin. Seemed to be working well for many, so I am assuming this is a simple oversight on my part perhaps.

    When I do a run of the demo, when clicking the Sign in with Twitter button on the connect.php page, I am properly directed to redirect.php but I get the following message (after the getRequestToken call):

    Could not connect to Twitter. Refresh the page or try again later.

    I cleared the session, refreshed etc and nothing worked. I took note of a few issues logged before and tried changing my callback to a real URL, as well as tried my own key and secret. I checked out the connection object and see that the response code is 401 (Unauthorized) instead of the expected 200.

    I can provide further details as needed, just seem to be having a lot of trouble with Twitter OAuth and hoped this plugin could help.

    Thanks!

    opened by 2bdev 18
  • SSL Error?

    SSL Error?

    Suddenly all my scripts are saying this:

    Fatal error: Uncaught exception 'Abraham\TwitterOAuth\TwitterOAuthException' with message 'SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed' in /home/gramaco/public_html/random/twitteroauth/src/TwitterOAuth.php:403 Stack trace: #0 /home/gramaco/public_html/random/twitteroauth/src/TwitterOAuth.php(334): Abraham\TwitterOAuth\TwitterOAuth->request('https://api.twi...', 'GET', 'Authorization: ...', Array) #1 /home/gramaco/public_html/random/twitteroauth/src/TwitterOAuth.php(305): Abraham\TwitterOAuth\TwitterOAuth->oAuthRequest('https://api.twi...', 'GET', Array) #2 /home/gramaco/public_html/random/twitteroauth/src/TwitterOAuth.php(179): Abraham\TwitterOAuth\TwitterOAuth->http('GET', 'https://api.twi...', 'account/verify_...', Array) #3 /home/gramaco/public_html/random/rilkbaudtweet.php(76): Abraham\TwitterOAuth\TwitterOAuth->get('account/verify_...') #4 {main} thrown in /home/gramaco/public_html/random/twitteroauth/src/TwitterOAuth.php on line 403

    I thought that maybe was a server ssl problem but no, they say everything is OK with their certificates. I'm missing something?

    Waiting on 
    opened by prandam 17
  • Passing objects as parameters

    Passing objects as parameters

    Hi, Firstly, thanks for creating this - it's been incredibly simple to use. However, I'm having difficulty in passing an object as a parameter for the new alt text support Twitter has introduced. According to https://blog.twitter.com/2016/alt-text-support-for-twitter-cards-and-the-rest-api they want the alt text to be in this format: { "media_id": "650011250680795136", "alt_text": { "text": "dancing cat" } } I've tried passing objects, arrays, using json_decode with their example string to get the right format and all sorts, and every time I get object(stdClass)#7 (2) { ["request"]=> string(31) "/1.1/media/metadata/create.json" ["error"]=> string(21) "Invalid json payload." } back.

    Currently I'm trying: $altText = (object) ['text' => 'An image generated in the style of a medieval Herbarium']; $parameters = [ 'alt_text' => $altText, 'media_id' => $media->media_id_string ]; $result = $connection->post('media/metadata/create', $parameters); but, as with my other attempts, getting that invalid json payload error.

    Is there a way to do this? Am I just doing something wrong?

    Many thanks for any help.

    Misc Available API support 
    opened by johnholtripley 17
  • Weird follower count bug

    Weird follower count bug

    Not sure why this is happening..

    I am using the code below to display a twitter follower count. What's happening is it displays fine here on the script im working on > http://ngx2gaming.com/kjthadon_social/

    Although once I include the file above onto the front page sidebar of the site, twitter is the only one that wont display .. As you can see here http://ngx2gaming.com/

    Anyone have an idea why it wont display on my front page, but will when I access the file directly?

    Thanks

    <?php
    require_once ('twitteroauth.php');
    require_once ('OAuth.php');
    
    $twitter_id = 'ngx2gaming';
    $twitter_access_token = 'xxx';
    $twitter_access_token_secret = 'xxx';
    $twitter_consumer_key = 'xxx';
    $twitter_consumer_secret = 'xxx';
    
    $twitter_api = new TwitterOAuth( $twitter_consumer_key , $twitter_consumer_secret , $twitter_access_token , $twitter_access_token_secret );
    $twitter_api_link = $twitter_api->get( 'users/lookup' , array ( 'screen_name' => ( $twitter_id ) ) );
    $twitter_count = $twitter_api_link[0]->followers_count;
    echo $twitter_count;
    ?>
    
    opened by KJThaDon 17
  • Direct message new API returning NULL

    Direct message new API returning NULL

    Hi Sir

    I am using the following code and library functions to use twitter API's

    require "vendor/autoload.php";
    
    use Abraham\TwitterOAuth\TwitterOAuth;
    $consumerKey 					= 'vT********************RQy';
    $consumerSecret 				= 'hdJqg*****************o************************MF0';
    $accessToken 					= "8**********************************************a6I";
    $accessSecret 					= "zYJ********************************************dRH";
    $baseUrl 						=  "http://******************/";
    $redirectURL 					= 'http://******************/';
    
    
    $connection = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken, $accessSecret);
    $content = $connection->get("account/verify_credentials");
    $connection->setTimeouts(10, 15);
    echo "<pre>"; print_r($content);echo "</pre>"; 
    $userId = "1027************96 ";
    
     $userDtaRes = $connection->get('users/lookup ', array('screen_name' => "Easemymarketing")); 
     print_r("<br/> user lookup API <br/>");
    var_dump("<br/>".$connection->getLastHttpCode());
    var_dump("<br/>".$connection->getLastApiPath());
    var_dump("<br/>".$userDtaRes);
    
    
    
    $data = [
        'event' => [
            'type' => 'message_create',
            'message_create' => [
                'target' => [
                    'recipient_id' => $userId
                ],
                'message_data' => [
                    'text' => "hi new dm messg to ashsi "
                ]
            ]
        ]
    ];
    
    $result = $connection->post('direct_messages/events/new ', $data, true); // Note the true
    print_r("<br/> USER send direct mesage api <br/>");
    var_dump("<br/>".$connection->getLastHttpCode());
    
    var_dump("<br/>".$result);
    

    Always it returns NULL for each library, please guide me how to run the to fetch various API result and send the direct message event new.

    Waiting on 
    opened by hlashish 15
  • Bump rector/rector from 0.14.8 to 0.15.2

    Bump rector/rector from 0.14.8 to 0.15.2

    Bumps rector/rector from 0.14.8 to 0.15.2.

    Release notes

    Sourced from rector/rector's releases.

    Released Rector 0.15.2

    New Features :partying_face:

    • [TypeDeclaration] Add FalseReturnClassMethodToNullableRector (#3229)
    • [DeadCode] Add TargetRemoveClassMethodRector (#3240)
    • Adapt PrivateConstantToSelfRector to work on non-final classes, too (#3198), Thanks @​alfredbez!
    • [CodingStyle] Add NullifyUnionNullableRector (#3231)
    • [TypeCoverage] Add EmptyOnNullableObjectToInstanceOfRector (#3230)
    • RenameClassRector with callback support (#3023), Thanks @​dorrogeray!

    Bugfixes :bug:

    • [Php82] Handle parent already readonly on ReadOnlyClassRector (#3199)
    • [DeadCode] Skip append array data on RemoveJustPropertyFetchRector (#3201)
    • [DeadCode] Skip standalone @​return false or true on RemoveUselessReturnTagRector (#3202)
    • Fix wrong reference to replacement rule (#3203), Thanks @​jlherren!
    • [Privatization] Do not remove comment on ChangeReadOnlyPropertyWithDefaultValueToConstantRector (#3204)
    • [Naming] Skip Doctrine collection with @​var Collection on RenamePropertyToMatchTypeRector (#3209)
    • [Core] Performance improvement: Remove unnecessary re-call FileFactory::createFileInfosFromPaths() (#3210)
    • [Php71] Skip defer() function on RemoveExtraParametersRector (#3211)
    • [Core] Improve performance: remove repetitive currentFileProvider->setFile() call on PhpFileProcessor (#3213)
    • [Php81] Allow explicit mixed processed on trait on NullToStrictStringFuncCallArgRector (#3212)
    • [Privatization] Skip used by heredoc on ChangeReadOnlyVariableWithDefaultValueToConstantRector (#3216)
    • [Parallel] Fix missing process RemovedAndAddedFilesProcessor->run() on parallel process on WorkerRunner (#3218)
    • [parallel] Improve performance: Run RemovedAndAddeedFileProcessor after loop (#3219)
    • [CodeQuality] Add empty() check to FlipTypeControlToUseExclusiveTypeRector (#3224)
    • [CodeQuality][TypeDeclaration] Handle default value from constructor removed on InlineConstructorDefaultToPropertyRector+TypedPropertyFromStrictConstructorRector (#3225)
    • [TypeDeclaration] Skip yield return on AddClosureReturnTypeRector (#3227)
    • [TypeDeclaration] Skip optional yield on AddReturnTypeDeclarationFromYieldsRector (#3228)
    • [NodeTraverser] Use NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN instead of NodeTraverser::DONT_TRAVERSE__CHILDREN (#3233)
    • [Core] Improve performance on AstResolver and ClassLikeAstResolver (#3234)
    • [Php81] Skip ReadOnlyPropertyRector on read only class (#3236)
    • [CodingStyle] Skip new line /\r\n|\r|\n/i on ConsistentPregDelimiterRector (#3241)
    • [CodingStyle] Skip EncapsedStringsToSprintfRector on heredoc (#3242)

    Released Rector 0.15.1

    New Features :partying_face:

    • [CodingStyle] Split SplitGroupedConstantsAndPropertiesRector to SplitGroupedClassConstantsRector and SplitGroupedPropertiesRector (#3158)
    • Add compatible phpstan/phpdoc-parser 0.15 (#3157)

    Bugfixes :bug:

    • Skip short class names in UseClassKeywordForClassNameResolutionRector (#3156)
    • [Core] Fix crash indentation on indent(\t, 1) config (#3155)
    • [TypeDeclaration] Skip union mixed on TypedPropertyFromAssignsRector (#3160)

    ... (truncated)

    Commits
    • 5bc89fa Rector 0.15.2
    • 5b34b97 Updated Rector to commit f8814b1d707d72e284870759d1f446848fa003b2
    • 374d2f5 Updated Rector to commit f8814b1d707d72e284870759d1f446848fa003b2
    • 5003a01 Updated Rector to commit e920ade7b67a17dbf7e6129585a3261f1fd1540e
    • f233f27 Updated Rector to commit ab3ad293122bafa96d9e8fc64ac15f0220aa9ecc
    • 727b9f4 Updated Rector to commit bfa1891c50677b01136a9308fd3c3ecc12e267d9
    • 680ba23 Updated Rector to commit 88629427917b7d359beeb1a0b34d39d2127472b9
    • e4dc601 Updated Rector to commit 3c168f03d38bb967a5e65e453f82adf120ef4eba
    • 96d8a22 Updated Rector to commit 70fea54e77ffd186e41540d2b36c5362b073fbc4
    • d72c810 Updated Rector to commit c78e255cf9cb17cedead84ff8a54f421f563942d
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies php 
    opened by dependabot[bot] 1
  • Unauthorized 401 when updating list meta data with PUT request

    Unauthorized 401 when updating list meta data with PUT request

    What are you attempting to do Trying to update a lists meta data using a PUT request

    Expected behavior The list should update

    Actual behavior An error is received

    }
      "title": "Unauthorized"
      "type": "about:blank"
      "status": 401
      "detail": "Unauthorized"
    }
    

    Code example

    $resp = $connection->put("lists/1", ["name" => "new name", "description" => "new description, yo!", "private" => false], true);
    

    List ID omitted for security reasons/

    Versions:

    • TwitterOAuth: [e.g. v3.3.0]
    • PHP: v [e.g. v8.1]

    Additional context The same request does work via Postman

    Bug Triage 
    opened by brandymedia 3
  • Unsupported Authentication

    Unsupported Authentication

    What are you attempting to do Add rules to Filtered Stream

    Expected behavior Return a array with the rules

    Actual behavior

    Return a 403

    object(stdClass)#4 (4) {
      ["title"]=>
      string(26) "Unsupported Authentication"
      ["detail"]=>
      string(141) "Authenticating with OAuth 1.0a User Context is forbidden for this endpoint.  Supported authentication types are [OAuth 2.0 Application-Only]."
      ["type"]=>
      string(61) "https://api.twitter.com/2/problems/unsupported-authentication"
      ["status"]=>
      int(403)
    }
    

    Code example

    $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret);
    $connection->setApiVersion('2');
    $rules_arr=[
      'add' => 
      [
          'value' => 'term1',
      ],
      [
          'value' => 'term2',
      ],
    ];
    $result = $connection->post('tweets/search/stream/rules/',$rules_arr,true);
    var_dump($result);
    

    Versions:

    • TwitterOAuth: [e.g. v4.0.1]
    • PHP: v [e.g. v8.1.11]

    Additional context Add any other context about the problem here.

    Bug Triage 
    opened by HackerGaucho 0
  • Add functions to create or delete subtitles for video files

    Add functions to create or delete subtitles for video files

    The API endpoints for managing subtitles associated with video files (media/subtitles/create and media/subtitles/delete) are not yet covered by this library. This pull request adds support for those endpoints.

    opened by cschoenfeld 0
Releases(4.0.1)
Owner
Abraham Williams
Developer Advocate
Abraham Williams
OAuth 1/2 Provider implementations for chillerlan/php-oauth-core. PHP 7.4+

chillerlan/php-oauth-providers Documentation See the wiki for advanced documentation. Requirements PHP 7.4+ a PSR-18 compatible HTTP client library of

chillerlan 4 Dec 2, 2022
PHPoAuthLib provides oAuth support in PHP 7.2+ and is very easy to integrate with any project which requires an oAuth client.

PHPoAuthLib NOTE: I'm looking for someone who could help to maintain this package alongside me, just because I don't have a ton of time to devote to i

David Desberg 1.1k Dec 27, 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
Laravel wrapper around OAuth 1 & OAuth 2 libraries.

Introduction Laravel Socialite provides an expressive, fluent interface to OAuth authentication with Facebook, Twitter, Google, LinkedIn, GitHub, GitL

The Laravel Framework 5.2k Dec 27, 2022
EAuth extension allows to authenticate users by the OpenID, OAuth 1.0 and OAuth 2.0 providers

EAuth extension allows to authenticate users with accounts on other websites. Supported protocols: OpenID, OAuth 1.0 and OAuth 2.0.

Maxim Zemskov 330 Jun 3, 2022
A simple twitter SDK to interact with Twitter api (1.1)

Twitter SDK Installation composer require lyrixx/twitter-sdk Usage Create a twitter application then <?php require __DIR__.'/vendor/autoload.php';

Grégoire Pineau 37 Aug 28, 2020
PHP 5.3+ oAuth 1/2 Client Library

PHPoAuthLib NOTE: I'm looking for someone who could help to maintain this package alongside me, just because I don't have a ton of time to devote to i

David Desberg 1.1k Dec 27, 2022
Open source social sign on PHP Library. HybridAuth goal is to act as an abstract api between your application and various social apis and identities providers such as Facebook, Twitter and Google.

Hybridauth 3.7.1 Hybridauth enables developers to easily build social applications and tools to engage websites visitors and customers on a social lev

hybridauth 3.3k Dec 23, 2022
The Salla OAuth Client library is designed to provide client applications with secure delegated access to Salla Merchant stores.

Salla Provider for OAuth 2.0 Client This package provides Salla OAuth 2.0 support for the PHP League's OAuth 2.0 Client. To use this package, it will

Salla 14 Nov 27, 2022
OAuth server implementation for WP API

WP REST API - OAuth 1.0a Server Connect applications to your WordPress site without ever giving away your password. This plugin uses the OAuth 1.0a pr

WordPress REST API Team 314 Dec 10, 2022
A spec compliant, secure by default PHP OAuth 2.0 Server

PHP OAuth 2.0 Server league/oauth2-server is a standards compliant implementation of an OAuth 2.0 authorization server written in PHP which makes work

The League of Extraordinary Packages 6.2k Jan 4, 2023
Kaiju is an open source verification bot based on Discord's OAuth written in C# and PHP, with the functionality of being able to integrate the user to a new server in case yours is suspended.

What is Kaiju? Kaiju is an open source verification bot for Discord servers, based on OAuth and with permission for the server owner, to be able to mi

in the space 10 Nov 20, 2022
Easy integration with OAuth 2.0 service providers.

OAuth 2.0 Client This package provides a base for integrating with OAuth 2.0 service providers. The OAuth 2.0 login flow, seen commonly around the web

The League of Extraordinary Packages 3.4k Dec 31, 2022
OAuth 1 Client

OAuth 1.0 Client OAuth 1 Client is an OAuth RFC 5849 standards-compliant library for authenticating against OAuth 1 servers. It has built in support f

The League of Extraordinary Packages 907 Dec 16, 2022
OAuth client integration for Symfony. Supports both OAuth1.0a and OAuth2.

HWIOAuthBundle The HWIOAuthBundle adds support for authenticating users via OAuth1.0a or OAuth2 in Symfony. Note: this bundle adds easy way to impleme

Hardware Info 2.2k Dec 30, 2022
An OAuth 2.0 bridge for Laravel and Lumen [DEPRECATED FOR LARAVEL 5.3+]

OAuth 2.0 Server for Laravel (deprecated for Laravel 5.3+) Note: This package is no longer maintaned for Laravel 5.3+ since Laravel now features the P

Luca Degasperi 2.4k Jan 6, 2023
This module is intended to provide oauth authentication to freescout.

OAuth FreeScout This module is intended to provide oauth authentication to freescout. Module was tested on keycloak oauth provider with confidential o

Michael Bolsunovskyi 9 Dec 21, 2022
A Laravel 5 package for OAuth Social Login/Register implementation using Laravel socialite and (optionally) AdminLTE Laravel package

laravel-social A Laravel 5 package for OAuth Social Login/Register implementation using Laravel socialite and (optionally) AdminLTE Laravel package. I

Sergi Tur Badenas 42 Nov 29, 2022
OAuth Service Provider for Laravel 4

OAuth wrapper for Laravel 4 oauth-4-laravel is a simple laravel 4 service provider (wrapper) for Lusitanian/PHPoAuthLib which provides oAuth support i

Dariusz Prząda 693 Sep 5, 2022