Download the PHP package nixilla/twitter-api-consumer without Composer

On this page you can find all versions of the php package nixilla/twitter-api-consumer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package twitter-api-consumer

Twitter API Consumer

_

This is the small library to make calls to Twitter API. It uses kriswallsmith/buzz for HTTP.

Twitter API supports OAuth2 but for application-only authentication. This library currently supports OAuth2, but there are plans for OAuth1a too.

The concept for this library is to use Twitter API with as small as 4 lines of code

If you're using Symfony2 and Dependecy Injection you can even do this is 3 lines

By default the $result variable contains Result object implementing ArrayAccess, Countable, Iterator interfaces, with the structure equivalent to json response from the Twitter API. It gets it from DefaultConverter class. However you can change it, by using converters. Converter is the special class that implements ConverterInterface with just one method "convert". It gets raw input as a parameter, which by default is json string.

You can inject converter class for given API method into $consumer object like this:

And converter class is very simple and can look like this:

return array('data' => $result['statuses'], 'metainfo' => $result['search_metadata']);

Of course you can do more complicated conversion, like creating and persisting database objects and return for example Doctrine ArrayCollection.

The whole point of converter class is to externalize data conversion from one format to another and give you control over it. You can (and you should) inject converters via DI in Symfony2 like this (this is just an example):

yaml

twitter.consumer: class: %twitter.oauth2.consumer.class% arguments: [ @buzz, %twitter.app_id%, %twitter.secret% ] calls: - [ setConverter , ["/1.1/search/tweets.json", "@tweet.converter" ] ]

You can also paginate over the result. All you need to do is to make sure that your converter class returns following key:

The class TwitterSearchConverter above is the example converter which you can use for result pagination. This is how you do it:

$result = $consumer->execute($query); $api_calls++;

do { printf("Queried %s times, last time found %s tweets\n", $api_calls, count($result));

foreach($result as $key => $tweet) echo $tweet['text'] . "\n";

} while(($result = $consumer->execute($result->nextQuery())) && $api_calls++);

Installation

Via composer (don't use 0.2 - it's broken).

{
    "require": {
        "nixilla/twitter-api-consumer": "~0.3"
    }
}

Tests

This is copy/paste command

sh

git clone https://github.com/nixilla/twitter-api-consumer.git && \ cd twitter-api-consumer && \ mkdir bin && \ curl -sS https://getcomposer.org/installer | php -- --install-dir=bin && \ ./bin/composer.phar install --dev && \ ./bin/phpunit


All versions of twitter-api-consumer with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.2
kriswallsmith/buzz Version ~0.8
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nixilla/twitter-api-consumer contains the following files

Loading the files please wait ....