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.


It's pretty simple to use:

    use StasisMedia\OAuth;

    $consumerCredential = new OAuth\Credential\Consumer('key',
    $request = new OAuth\Request\RequestToken($consumerCredential,
    $signature = new OAuth\Signature\HMAC_SHA1($request,

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

    echo $authHeader;
     * Authorization: OAuth realm="realm", oauth_consumer_key="key",
     * oauth_timestamp="1288534693",
     * 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
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: 

Reply via email to