Skip to content

Instantly share code, notes, and snippets.

@daviddesberg
Last active December 12, 2015 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daviddesberg/4760647 to your computer and use it in GitHub Desktop.
Save daviddesberg/4760647 to your computer and use it in GitHub Desktop.
Creating a Twitter OAuth1 Service
<?php
use OAuth\ServiceFactory;
use OAuth\Common\Storage\Session;
use OAuth\Common\Consumer\Credentials;
// create a factory
// optional constructor argument defines the type of http client to use for the services this factory creates
$factory = new ServiceFactory();
// tokenstorageinterface implementation
$storage = new Session();
// Setup the credentials for the requests
$credentials = new Credentials(
'id',
'secret_key',
'http://yoursite.com/oauth-client',
);
// Instantiate the twitter service using the above credentials and storage provider
$twitterService = $serviceFactory->createService('twitter', $credentials, $storage);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment