2016-03-07 21:42:05 +03:00
|
|
|
:: A Twitter API library.
|
|
|
|
::
|
|
|
|
:::: /hoon/twitter/lib
|
|
|
|
::
|
|
|
|
/? 314
|
2016-03-08 00:42:23 +03:00
|
|
|
/- twitter
|
2016-04-07 23:07:21 +03:00
|
|
|
/+ interpolate, hep-to-cab
|
2016-03-08 00:42:23 +03:00
|
|
|
=+ sur-twit:^twitter :: XX
|
2016-12-07 06:13:33 +03:00
|
|
|
=, eyre
|
2016-12-03 03:56:54 +03:00
|
|
|
=, mimes:html
|
2016-12-03 03:11:54 +03:00
|
|
|
=, html
|
2016-12-02 02:27:39 +03:00
|
|
|
=, format
|
2016-12-03 04:11:44 +03:00
|
|
|
=, html
|
2016-12-01 04:22:43 +03:00
|
|
|
=, chrono:userlib
|
2016-11-17 04:42:58 +03:00
|
|
|
::
|
2016-03-07 21:42:05 +03:00
|
|
|
:::: functions
|
|
|
|
::
|
|
|
|
|%
|
2016-03-09 07:25:44 +03:00
|
|
|
++ join
|
|
|
|
|= {a/char b/(list @t)} ^- @t
|
|
|
|
%+ rap 3
|
|
|
|
?~ b ~
|
2017-07-21 00:20:56 +03:00
|
|
|
|-(?~(t.b b [i.b a $(b t.b)]))
|
2016-03-09 07:25:44 +03:00
|
|
|
::
|
2016-03-07 21:42:05 +03:00
|
|
|
++ valve :: produce request
|
2016-03-11 07:37:47 +03:00
|
|
|
|= {med/?($get $post) pax/path quy/quay}
|
2016-03-07 21:42:05 +03:00
|
|
|
^- hiss
|
2016-12-03 04:11:44 +03:00
|
|
|
=+ url=(scan "https://api.twitter.com/1.1/.json" auri:de-purl) :: base path
|
2016-03-09 06:49:58 +03:00
|
|
|
=. q.q.url (welp q.q.url pax)
|
2016-03-09 23:52:57 +03:00
|
|
|
=. r.url quy
|
2016-03-10 05:36:07 +03:00
|
|
|
^- hiss
|
2016-03-09 06:49:58 +03:00
|
|
|
?- med
|
2016-03-09 23:52:57 +03:00
|
|
|
$get [url med *math ~]
|
2016-03-09 06:49:58 +03:00
|
|
|
$post
|
2017-09-08 02:47:49 +03:00
|
|
|
=+ hed=(my:nl content-type+['application/x-www-form-urlencoded']~ ~)
|
2016-12-03 04:11:44 +03:00
|
|
|
[url(r ~) med hed ?~(r.url ~ (some (as-octt +:(tail:en-purl r.url))))]
|
2016-03-09 06:49:58 +03:00
|
|
|
==
|
2016-03-12 01:54:29 +03:00
|
|
|
::
|
|
|
|
++ find-req
|
|
|
|
=+ all=doc-data-dry:reqs
|
|
|
|
|= a/_-:*endpoint:reqs ^- {?($get $post) path}
|
|
|
|
?~ all ~|(endpoint-lost+a !!) :: type error, should never happen
|
|
|
|
?: =(a -:*typ.i.all)
|
|
|
|
+.i.all
|
|
|
|
$(all t.all)
|
2016-03-07 21:42:05 +03:00
|
|
|
--
|
2016-11-17 04:42:58 +03:00
|
|
|
::
|
2016-03-07 21:42:05 +03:00
|
|
|
:::: library
|
|
|
|
::
|
|
|
|
|%
|
2016-03-09 07:32:45 +03:00
|
|
|
++ render :: response printers
|
2016-04-01 02:15:10 +03:00
|
|
|
=+ args:reqs
|
2016-03-07 21:42:05 +03:00
|
|
|
|%
|
|
|
|
++ mean
|
2016-03-08 04:38:01 +03:00
|
|
|
|= {msg/@t num/@ud} ^- tank
|
|
|
|
rose+[": " `~]^~[leaf+"Error {<num>}" leaf+(trip msg)]
|
2016-04-01 02:15:10 +03:00
|
|
|
::
|
|
|
|
++ user-url
|
2016-04-01 03:39:48 +03:00
|
|
|
|= a/scr ^- purf
|
2016-04-14 23:18:24 +03:00
|
|
|
:_ ~
|
|
|
|
%^ into-url:interpolate 'https://twitter.com/:scr'
|
|
|
|
~
|
|
|
|
~[scr+a]
|
2016-04-01 02:15:10 +03:00
|
|
|
::
|
|
|
|
++ post-url
|
2016-04-14 23:18:24 +03:00
|
|
|
|= {a/scr b/tid} ^- purf
|
|
|
|
:_ ~
|
|
|
|
%^ into-url:interpolate 'https://twitter.com/:scr/status/:tid'
|
|
|
|
~
|
2016-04-01 02:15:10 +03:00
|
|
|
~[scr+a tid+(tid:print b)]
|
2016-03-07 21:42:05 +03:00
|
|
|
--
|
2016-12-02 02:27:39 +03:00
|
|
|
++ parse ^? :: text parsers
|
2016-03-07 21:42:05 +03:00
|
|
|
|%
|
2016-12-02 02:27:39 +03:00
|
|
|
++ user (cook crip (plus ;~(pose aln cab)))
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ reparse :: json reparsers
|
|
|
|
=, parse
|
|
|
|
|%
|
|
|
|
++ ce =>(dejs |*({a/_* b/fist} (cu |=(c/a c) b))) :: output type
|
2016-10-24 20:36:01 +03:00
|
|
|
++ fasp |*(a/{@tas *} [(hep-to-cab -.a) +.a])
|
2016-12-02 02:27:39 +03:00
|
|
|
++ mean (ot errors+(ar (ot message+so code+ni ~)) ~):dejs
|
2016-03-21 23:35:29 +03:00
|
|
|
++ post
|
2016-12-02 02:27:39 +03:00
|
|
|
=, ^?(dejs)
|
2016-03-21 23:35:29 +03:00
|
|
|
%+ ce post:sur-twit
|
2016-03-07 21:42:05 +03:00
|
|
|
%- ot
|
2016-03-08 00:42:23 +03:00
|
|
|
:~ id+ni
|
2016-12-02 02:27:39 +03:00
|
|
|
user+(ot (fasp screen-name+(su user)) ~)
|
2016-11-24 03:35:43 +03:00
|
|
|
(fasp created-at+(cu year (ci stud so)))
|
2017-07-21 00:20:56 +03:00
|
|
|
:: parse html escapes and newlines
|
|
|
|
text+(cu crip (su (star ;~(pose (just `@`10) escp:de-xml))))
|
2016-03-07 21:42:05 +03:00
|
|
|
==
|
2017-07-21 00:20:56 +03:00
|
|
|
++ usel
|
2016-12-02 02:27:39 +03:00
|
|
|
=, ^?(dejs)
|
2016-03-12 03:06:47 +03:00
|
|
|
%+ ce (list who/@ta)
|
2016-03-08 00:42:23 +03:00
|
|
|
=- (ot users+(ar -) ~)
|
2016-12-02 02:27:39 +03:00
|
|
|
(ot (fasp screen-name+(su user)) ~)
|
2016-03-07 21:42:05 +03:00
|
|
|
--
|
2016-03-12 04:48:40 +03:00
|
|
|
++ print
|
|
|
|
=+ args:reqs
|
|
|
|
|%
|
|
|
|
++ tid |=(@u `@t`(rsh 3 2 (scot %ui +<)))
|
|
|
|
++ scr |=(@t +<)
|
|
|
|
++ lsc
|
|
|
|
|= a/$@(^scr ^lsc) ^- @t
|
|
|
|
?@(a `@t`a (join ',' a))
|
|
|
|
::
|
|
|
|
++ lid
|
|
|
|
|= a/$@(^tid (list ^tid)) ^- @t
|
|
|
|
?~ a ~|(%nil-id !!)
|
|
|
|
?@(a (tid a) (join ',' (turn `(list ^tid)`a tid)))
|
|
|
|
--
|
2016-03-12 01:54:29 +03:00
|
|
|
++ request
|
|
|
|
=< apex
|
|
|
|
=+ args:reqs
|
2016-03-11 07:37:47 +03:00
|
|
|
|%
|
2016-03-12 01:54:29 +03:00
|
|
|
++ apex
|
2016-03-22 21:49:04 +03:00
|
|
|
|= {a/endpoint b/quay} ^- hiss
|
2016-03-12 01:54:29 +03:00
|
|
|
=+ [med pax]=(find-req -.a)
|
|
|
|
(valve med (cowl pax +.a b))
|
|
|
|
::
|
2016-03-09 07:25:44 +03:00
|
|
|
++ lutt |=(@u `@t`(rsh 3 2 (scot %ui +<)))
|
2017-07-21 00:20:56 +03:00
|
|
|
++ llsc
|
2016-03-12 01:54:29 +03:00
|
|
|
:: => args:reqs
|
2016-03-09 07:25:44 +03:00
|
|
|
|= a/$@(scr (list scr)) ^- @t
|
|
|
|
?@(a `@t`a (join ',' a))
|
2016-03-07 21:42:05 +03:00
|
|
|
::
|
2017-07-21 00:20:56 +03:00
|
|
|
++ llst
|
2016-03-09 07:25:44 +03:00
|
|
|
|= a/$@(@t (list @t)) ^- @t
|
|
|
|
?@(a `@t`a (join ',' a))
|
2016-03-07 21:42:05 +03:00
|
|
|
::
|
|
|
|
++ llid
|
2016-03-12 01:54:29 +03:00
|
|
|
:: =+ args:reqs
|
2016-03-09 07:25:44 +03:00
|
|
|
|= a/$@(tid (list tid)) ^- @t
|
|
|
|
?~ a ~|(%nil-id !!)
|
|
|
|
?@(a (lutt a) (join ',' (turn `(list tid)`a lutt)))
|
2016-03-07 21:42:05 +03:00
|
|
|
::
|
|
|
|
++ cowl :: handle parameters
|
2017-07-21 00:20:56 +03:00
|
|
|
|= $: pax/path
|
2016-03-09 07:25:44 +03:00
|
|
|
ban/(list param)
|
2016-03-08 00:42:23 +03:00
|
|
|
quy/quay
|
2016-03-07 21:42:05 +03:00
|
|
|
==
|
2016-03-09 07:25:44 +03:00
|
|
|
^- {path quay}
|
2016-04-07 23:07:21 +03:00
|
|
|
%+ into-path-partial:interpolate
|
|
|
|
(path:hep-to-cab pax)
|
2016-03-09 07:25:44 +03:00
|
|
|
=- (weld - quy)
|
|
|
|
%+ turn ban
|
|
|
|
|= p/param
|
2016-03-08 04:38:01 +03:00
|
|
|
^- {@t @t}
|
2016-04-07 23:07:21 +03:00
|
|
|
:- (hep-to-cab -.p)
|
2016-03-09 07:25:44 +03:00
|
|
|
?+ -.p p.p :: usually plain text
|
2016-03-12 04:48:40 +03:00
|
|
|
?($source-id $target-id) (tid:print p.p)
|
2017-09-20 03:35:45 +03:00
|
|
|
?($id $name $user-id) (lid:print p.p)
|
2016-03-12 04:48:40 +03:00
|
|
|
$screen-name (lsc:print p.p)
|
2016-03-07 21:42:05 +03:00
|
|
|
==
|
|
|
|
--
|
|
|
|
--
|