Re: [WebDNA] Authenticating with Twitter OAuth API v1.1

This WebDNA talk-list message is from

2013


It keeps the original formatting.
numero = 110524
interpreted = N
texte = --047d7bdca4e611907104e2ca0846 Content-Type: text/plain; charset=UTF-8 David, Hi - here you go. It's very slow (maybe Twitter are rate limiting) so I use a trigger it to periodically write a json file to disk. You'll need to set up a Twitter App on their developer site and get a key/secret. - Tom [!] [/!][!] ------------------------------------ ### Restrict trigger to 15 minute intervals ### [/!][showif [time %M]\15][!] ------------------------------------ ### Set Variables ### [/!][text]con_key=[url]xxxxxxxxx[/url][/text][!] App Consumer Key [/!][text]con_secret=[url]xxxxxxxxx[/url][/text][!] App Consumer Secret [/!][text]screen_name=[url]target-handle[/url][/text][!] Twitter account we are targeting [/!][text]count=6[/text][!] Number of Tweets to return [/!][text]include_rts=1[/text][!] Set to 1 if retweets are to be included [/!][text]CRLF=[unurl]%0D%0A[/unurl][/text][!] CRLF Variable [/!][text]debug=F[/text][!] Show debug fields ------------------------------------ ### Get OAuth Credentials ### [/!][text]content=grant_type=client_credentials[/text][!] [/!][text]jsonResponse=[TCPConnect host=api.twitter.com&port=443&ssl=T][!] [/!][tcpsend skipheader=F]POST /oauth2/token HTTP/1.1[CRLF][!] [/!]Host: api.twitter.com[CRLF][!] [/!]User-Agent: Your-Twitter-App-Name[CRLF][!] [/!]Authorization: Basic [encrypt method=Base64][con_key]:[con_secret][/encrypt][CRLF][!] [/!]Content-type: application/x-www-form-urlencoded;charset=UTF-8[CRLF][!] [/!]Content-Length: [countchars][content][/countchars][CRLF][CRLF][!] Accept-Encoding: gzip[crlf][crlf][/!][!] [/!][content][CRLF][!] [/!][/tcpsend][/tcpconnect][/text][!] ## debug info ## [/!][showif [debug]=T]

OAuth Json Response

[jsonResponse]
[/showif][!] ------------------------------------ ### Set up Json Parse Convert table ### [/!][table name=jsonParseConvert&fields=from,to] " : = [/table][!] ------------------------------------ ### Parse Json ### [/!][listwords words=[url][jsonResponse][/url]&delimiters={},][text][convertwords table=jsonParseConvert][word][/convertwords][/text][/listwords][!] ## debug info ## [/!][showif [debug]=T]

OAuth Access Token

[access_token]
[/showif][!] ------------------------------------ ### Connect and pull down tweets - write to json file ### [/!][writefile file=client.json][!] [/!][TCPConnect host=api.twitter.com&port=443&ssl=T][!] [/!][TCPSend skipheader=T]GET /1.1/statuses/user_timeline.json?screen_name=[screen_name]&count=[count]&include_rts=[include_rts] HTTP/1.1[CRLF][!] [/!]Host: api.twitter.com[CRLF][!] [/!]User-Agent: DigRevs Twitter App v1[CRLF][!] [/!]Authorization: Bearer [access_token][CRLF][CRLF][/TCPSend][!] [/!][/TCPConnect][!] [/!][/writefile][!] ------------------------------------ ### Close restrict to 15 mins showif ### [/!][/showif] Complete --047d7bdca4e611907104e2ca0846 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
David,

Hi - here you go. =C2=A0 It'= s very slow (maybe Twitter are rate limiting) so I use a trigger it to peri= odically write a json file to disk. =C2=A0 You'll need to set up a Twit= ter App on their developer site and get a key/secret.

- Tom



[!]<!-- HAS_WEBDNA_TAGS -->
[/!][!]



------------------------------------
### =C2=A0Restrict = trigger to 15 minute intervals =C2=A0###

[/!][show= if [time %M]\15][!]


------------------------------------
### =C2=A0Set Varia= bles =C2=A0###

[/!][text]con_key=3D[url]xxxxxxxxx[= /url][/text][!] App Consumer Key
[/!][text]con_secret=3D[url]xxxx= xxxxx[/url][/text][!] App Consumer Secret

[/!][text]screen_name=3D[url]target-handle[/url][/text]= [!] Twitter account we are targeting
[/!][text]count=3D6[/text][!= ] Number of Tweets to return
[/!][text]include_rts=3D1[/text][!] = Set to 1 if retweets are to be included

[/!][text]CRLF=3D[unurl]%0D%0A[/unurl][/text][!] CRLF V= ariable
[/!][text]debug=3DF[/text][!] Show debug fields


= ------------------------------------
### =C2=A0Get OAuth= Credentials =C2=A0###

[/!][text]content=3Dgrant_t= ype=3Dclient_credentials[/text][!]

[/!][text]jsonR= esponse=3D[TCPConnect host=3Dapi.twitter= .com&port=3D443&ssl=3DT][!]
[/!][tcpsend skipheader=3DF]POST /oauth2/token HTTP/1.1[CRLF][!]
=
[/!]Host: api.twitter.com[CRLF]= [!]
[/!]User-Agent: Your-Twitter-App-Name[CRLF][!]
[/!]= Authorization: Basic [encrypt method=3DBase64][con_key]:[con_secret][/encry= pt][CRLF][!]
[/!]Content-type: application/x-www-form-urlencoded;charset=3DUTF-8[CR= LF][!]
[/!]Content-Length: [countchars][content][/countchars][CRL= F][CRLF][!]
Accept-Encoding: gzip[crlf][crlf][/!][!]
[/!][content][CRLF][!]
[/!][/tcpsend][/tcpconnect][/text][!]

## debug info ##
[/!][showif [debug]=3DT]<= ;h3>OAuth Json Response</h3>
<pre>[jsonResponse]&l= t;/pre>[/showif][!]


------------------------------------
### =C2=A0Set up Json Parse Convert table= =C2=A0###

[/!][table name=3DjsonParseConvert&fields=3Dfrom,to= ]
"
=
:=3D
[/ta= ble][!]


------------------------------------
### =C2=A0Parse Json =C2=A0###
=
[/!][listwords words=3D[url][jsonResponse][/url]&delimiters=3D{},][text= ][convertwords table=3DjsonParseConvert][word][/convertwords][/text][/listw= ords][!]


## debug info ##
[/!][showif [debug]=3DT]<h3>OAuth Access Token</h3>
<pre>[access_token]</pre>[/showif][!]

=

----= --------------------------------
### =C2=A0Connect and pull down tweets - write to json f= ile =C2=A0###

[/!][writefile file=3Dclient.json][!]

[/!][TCPConnect = host=3Dapi.twitter.com&port=3D44= 3&ssl=3DT][!]
[/!][TCPSend skiph= eader=3DT]GET /1.1/statuses/user_timeline.json?screen_name=3D[screen_name]&= amp;count=3D[count]&include_rts=3D[include_rts] HTTP/1.1[CRLF][!]
=
[/!]Host: api.twitter.com[CRLF][!]
[/!]User-Agent: Di= gRevs Twitter App v1[CRLF][!]
[/!]Authorization: Bearer [access_token][CRLF][CRLF][/TCPS= end][!]
[/!][/TCPConnect][!= ]

[/!][/writefile][!]

------------= ------------------------
### =C2=A0Close res= trict to 15 mins showif =C2=A0###

[/!][/showif]


Complete

--047d7bdca4e611907104e2ca0846-- Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] Authenticating with Twitter OAuth API v1.1 (Tom Duke 2013)
  2. Re: [WebDNA] Authenticating with Twitter OAuth API v1.1 (David Bastedo 2013)
  3. Re: [WebDNA] Authenticating with Twitter OAuth API v1.1 (Tom Duke 2013)
  4. Re: [WebDNA] Authenticating with Twitter OAuth API v1.1 (David Bastedo 2013)
  5. Re: [WebDNA] Authenticating with Twitter OAuth API v1.1 (Tom Duke 2013)
  6. Re: [WebDNA] Authenticating with Twitter OAuth API v1.1 (Tom Duke 2013)
  7. Re: [WebDNA] Authenticating with Twitter OAuth API v1.1 (Paul Willis 2013)
  8. [WebDNA] Authenticating with Twitter OAuth API v1.1 (Tom Duke 2013)
--047d7bdca4e611907104e2ca0846 Content-Type: text/plain; charset=UTF-8 David, Hi - here you go. It's very slow (maybe Twitter are rate limiting) so I use a trigger it to periodically write a json file to disk. You'll need to set up a Twitter App on their developer site and get a key/secret. - Tom [!] [/!][!] ------------------------------------ ### Restrict trigger to 15 minute intervals ### [/!][showif [time %M]\15][!] ------------------------------------ ### Set Variables ### [/!][text]con_key=[url]xxxxxxxxx[/url][/text][!] App Consumer Key [/!][text]con_secret=[url]xxxxxxxxx[/url][/text][!] App Consumer Secret [/!][text]screen_name=[url]target-handle[/url][/text][!] Twitter account we are targeting [/!][text]count=6[/text][!] Number of Tweets to return [/!][text]include_rts=1[/text][!] Set to 1 if retweets are to be included [/!][text]CRLF=[unurl]%0D%0A[/unurl][/text][!] CRLF Variable [/!][text]debug=F[/text][!] Show debug fields ------------------------------------ ### Get OAuth Credentials ### [/!][text]content=grant_type=client_credentials[/text][!] [/!][text]jsonResponse=[TCPConnect host=api.twitter.com&port=443&ssl=T][!] [/!][tcpsend skipheader=F]POST /oauth2/token HTTP/1.1[CRLF][!] [/!]Host: api.twitter.com[CRLF][!] [/!]User-Agent: Your-Twitter-App-Name[CRLF][!] [/!]Authorization: Basic [encrypt method=Base64][con_key]:[con_secret][/encrypt][CRLF][!] [/!]Content-type: application/x-www-form-urlencoded;charset=UTF-8[CRLF][!] [/!]Content-Length: [countchars][content][/countchars][CRLF][CRLF][!] Accept-Encoding: gzip[crlf][crlf][/!][!] [/!][content][CRLF][!] [/!][/tcpsend][/tcpconnect][/text][!] ## debug info ## [/!][showif [debug]=T]

OAuth Json Response

[jsonResponse]
[/showif][!] ------------------------------------ ### Set up Json Parse Convert table ### [/!][table name=jsonParseConvert&fields=from,to] " : = [/table][!] ------------------------------------ ### Parse Json ### [/!][listwords words=[url][jsonResponse][/url]&delimiters={},][text][convertwords table=jsonParseConvert][word][/convertwords][/text][/listwords][!] ## debug info ## [/!][showif [debug]=T]

OAuth Access Token

[access_token]
[/showif][!] ------------------------------------ ### Connect and pull down tweets - write to json file ### [/!][writefile file=client.json][!] [/!][TCPConnect host=api.twitter.com&port=443&ssl=T][!] [/!][TCPSend skipheader=T]GET /1.1/statuses/user_timeline.json?screen_name=[screen_name]&count=[count]&include_rts=[include_rts] HTTP/1.1[CRLF][!] [/!]Host: api.twitter.com[CRLF][!] [/!]User-Agent: DigRevs Twitter App v1[CRLF][!] [/!]Authorization: Bearer [access_token][CRLF][CRLF][/TCPSend][!] [/!][/TCPConnect][!] [/!][/writefile][!] ------------------------------------ ### Close restrict to 15 mins showif ### [/!][/showif] Complete --047d7bdca4e611907104e2ca0846 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
David,

Hi - here you go. =C2=A0 It'= s very slow (maybe Twitter are rate limiting) so I use a trigger it to peri= odically write a json file to disk. =C2=A0 You'll need to set up a Twit= ter App on their developer site and get a key/secret.

- Tom



[!]<!-- HAS_WEBDNA_TAGS -->
[/!][!]



------------------------------------
### =C2=A0Restrict = trigger to 15 minute intervals =C2=A0###

[/!][show= if [time %M]\15][!]


------------------------------------
### =C2=A0Set Varia= bles =C2=A0###

[/!][text]con_key=3D[url]xxxxxxxxx[= /url][/text][!] App Consumer Key
[/!][text]con_secret=3D[url]xxxx= xxxxx[/url][/text][!] App Consumer Secret

[/!][text]screen_name=3D[url]target-handle[/url][/text]= [!] Twitter account we are targeting
[/!][text]count=3D6[/text][!= ] Number of Tweets to return
[/!][text]include_rts=3D1[/text][!] = Set to 1 if retweets are to be included

[/!][text]CRLF=3D[unurl]%0D%0A[/unurl][/text][!] CRLF V= ariable
[/!][text]debug=3DF[/text][!] Show debug fields


= ------------------------------------
### =C2=A0Get OAuth= Credentials =C2=A0###

[/!][text]content=3Dgrant_t= ype=3Dclient_credentials[/text][!]

[/!][text]jsonR= esponse=3D[TCPConnect host=3Dapi.twitter= .com&port=3D443&ssl=3DT][!]
[/!][tcpsend skipheader=3DF]POST /oauth2/token HTTP/1.1[CRLF][!]
=
[/!]Host: api.twitter.com[CRLF]= [!]
[/!]User-Agent: Your-Twitter-App-Name[CRLF][!]
[/!]= Authorization: Basic [encrypt method=3DBase64][con_key]:[con_secret][/encry= pt][CRLF][!]
[/!]Content-type: application/x-www-form-urlencoded;charset=3DUTF-8[CR= LF][!]
[/!]Content-Length: [countchars][content][/countchars][CRL= F][CRLF][!]
Accept-Encoding: gzip[crlf][crlf][/!][!]
[/!][content][CRLF][!]
[/!][/tcpsend][/tcpconnect][/text][!]

## debug info ##
[/!][showif [debug]=3DT]<= ;h3>OAuth Json Response</h3>
<pre>[jsonResponse]&l= t;/pre>[/showif][!]


------------------------------------
### =C2=A0Set up Json Parse Convert table= =C2=A0###

[/!][table name=3DjsonParseConvert&fields=3Dfrom,to= ]
"
=
:=3D
[/ta= ble][!]


------------------------------------
### =C2=A0Parse Json =C2=A0###
=
[/!][listwords words=3D[url][jsonResponse][/url]&delimiters=3D{},][text= ][convertwords table=3DjsonParseConvert][word][/convertwords][/text][/listw= ords][!]


## debug info ##
[/!][showif [debug]=3DT]<h3>OAuth Access Token</h3>
<pre>[access_token]</pre>[/showif][!]

=

----= --------------------------------
### =C2=A0Connect and pull down tweets - write to json f= ile =C2=A0###

[/!][writefile file=3Dclient.json][!]

[/!][TCPConnect = host=3Dapi.twitter.com&port=3D44= 3&ssl=3DT][!]
[/!][TCPSend skiph= eader=3DT]GET /1.1/statuses/user_timeline.json?screen_name=3D[screen_name]&= amp;count=3D[count]&include_rts=3D[include_rts] HTTP/1.1[CRLF][!]
=
[/!]Host: api.twitter.com[CRLF][!]
[/!]User-Agent: Di= gRevs Twitter App v1[CRLF][!]
[/!]Authorization: Bearer [access_token][CRLF][CRLF][/TCPS= end][!]
[/!][/TCPConnect][!= ]

[/!][/writefile][!]

------------= ------------------------
### =C2=A0Close res= trict to 15 mins showif =C2=A0###

[/!][/showif]


Complete

--047d7bdca4e611907104e2ca0846-- Tom Duke

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

Grep Again (was: MySQL UPDATE) (2007) WebCatalog stalls (1998) Kaaaaahhhhhhhnnnnnnn! (1997) Unexpected error (1997) _ in front of field name (1998) Search returns all, not 20 (1997) bug in wn searching NT version? (1997) Freeze (2003) form data submission gets truncated (1997) [listfiles] nested in a [loop] (1998) [SHOWIF AND/OR] (1997) GuestBook example (1997) [taxrate] question (1997) [OT] Position vacant in Sydney, Australia (2006) Associative lookup style? + bit more (1997) Upgrading old WebCat Database Files (1997) Running 2 two WebCatalog.acgi's (1996) PHP Live (2005) taxRate is fine but taxTotal isn't (1997) CreateDate and ModDate issues (2004)