Hi All,

We've recently been developing a PHP 5.3 client for accessing Site
Streams API. One requirement was the ability to generate OAuth
signatures without being forced to use any specific connection
implementation, and without enforcing any particular token storage
mechanism. Just plain, basic OAuth signatures that we could use in
either a CURL or streaming-based request.

https://github.com/CraigMason/OAuth

It's pretty simple to use:

    use StasisMedia\OAuth;

    $consumerCredential = new OAuth\Credential\Consumer('key',
'secret');
    $request = new OAuth\Request\RequestToken($consumerCredential,
'http://example.com/request_token');
    $signature = new OAuth\Signature\HMAC_SHA1($request,
$consumerCredential);

    $authHeader = $request->getAuthorizationHeader('realm', $signature-
>generateSignature() );

    echo $authHeader;
    /*
     * Authorization: OAuth realm="realm", oauth_consumer_key="key",
     * oauth_timestamp="1288534693",
oauth_nonce="b0d75745b33346972e8cab2129f33bb5",
     * oauth_version="1.0", oauth_signature_method="HMAC-SHA1",
     * oauth_signature="%2B7mFGdwyRvMdQR1o%2FxJqyBcscpE%3D"
     */

$authHeader will contain the full HTTP Authorization header ready to
add to your CURL object or other socket connection.

There's also the handy `$request->reset()` which will generate a new
timestamp/nonce, so you can re-use the same $request, should your
stream get disconnected.

Hopefully this will be of help to anyone working on the new streaming
API, or PHP 5.3 clients in general. If you spot any issues, raise a
ticket on github.

Thanks, Craig
--
@CraigMason
http://www.stasismedia.com | http://www.tweetsms.com

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk

Reply via email to