Create Authorization Headers for Twitter API calls via xQuery
This lib only purpose is to enable calls to Twitter API endpoints via OAuth 1.0a protocol Authorization Header
Built upon 'http://expath.org/ns/crypto' cypto lib, version: 0.6'
which provides the cypto:hmac
function to calculate the signature.
You must obtain your twitter access token from the twitter apps dashboard You will end up with your 4 credential items
- oauth_consumer_key
- oauth_consumer_secret
- oauth_token_secret
- oauth_token
Next make yourself familiar with the Twitter API docs
The API call you are most likely interest in are in the post and engage overview section
Th following example shows how to use the library, with your obtained credentials. It creates the Authorization header string required for posting a status update to the Twitter 'statuses/update' API endpoint. The example data ( oauth_consumer_key etc ) come from the twitter creating signatures and authorizing-requests example code. The same example data has been used to test the library.
declare
function oAuth1:example() as xs:string {
map {
'method' : 'POST',
'resource' : 'https://api.twitter.com/1.1/statuses/update',
'oauth_consumer_key' : 'xvz1evFS4wEEPTGEFPHBog',
'oauth_consumer_secret' : 'kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw',
'oauth_token_secret' : '370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb',
'oauth_token' : 'LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE'
}
) =>
oAuth1:authorizationHeader(
map { 'status' : 'Hello Ladies + Gentlemen, a signed OAuth request!' }
)
)
};
├── Makefile => run `make test` calls `prove -v bin/xQtest`
├── bin
│ ├── xQtest -> produce TAP report
see if output from running example matches prescribed grep pattern
├── Makefile => run `make smoke` calls `bin/xQcall`
├── bin
│ ├── xQcall -> runs example
See if every function was called in lib by running example then inspecting trace
├── Makefile => run `make coverage `bin/xQcall`
├── bin
│ ├── xQcall -> enable tracing
-> run example
-> stop tracing
-> inpect trace