1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
  
     | 
    
      # documentation: http://delicious.com/help/api
package require rest
set delicious(updated) {
    url https://api.del.icio.us/v1/posts/update
    auth basic
    result raw
    post_transform {
        regexp {<update time=\"(.*?)\"} $result -> update
        return [clock scan [string map {T " " Z " UTC"} $update]]
    }
}
set delicious(add_post) {
    url https://api.del.icio.us/v1/posts/add
    auth basic
    req_args { url: description: }
    opt_args { extended: tags: dt: replace: shared: }
    check_result { {[regexp {<result code=\"done} $result]} {} }
}
set delicious(delete_post) {
    url https://api.del.icio.us/v1/posts/delete
    auth basic
    req_args { url: }
    check_result { {[regexp {<result code=\"done} $result]} {} }
}
set delicious(get_posts) {
    url https://api.del.icio.us/v1/posts/get
    auth basic
    opt_args { url: tag: dt: hashes: meta: }
}
set delicious(recent_posts) {
    url https://api.del.icio.us/v1/posts/recent
    auth basic
    opt_args { tag: }
}
set delicious(post_dates) {
    url https://api.del.icio.us/v1/posts/dates
    auth basic
    opt_args { tag: count: }
}
set delicious(get_all_posts) {
    url https://api.del.icio.us/v1/posts/all
    auth basic
    opt_args { tag: start: results: fromdt: todt: meta: }
}
set delicious(get_hashes) {
    url https://api.del.icio.us/v1/posts/all
    auth basic
    static_args { hashes {} }
}
set delicious(get_tags) {
    url https://api.del.icio.us/v1/tags/get
    auth basic
}
set delicious(delete_tag) {
    url https://api.del.icio.us/v1/tags/delete
    auth basic
    req_args { tag: }
    check_result { {[regexp {<result>done} $result]} {} }
}
set delicious(rename_tag) {
    url https://api.del.icio.us/v1/tags/rename
    auth basic
    req_args { old: new: }
    check_result { {[regexp {<result>done} $result]} {} }
}
set delicious(get_bundles) {
    url https://api.del.icio.us/v1/bundles/all
    auth basic
    opt_args { bundle: }
}
set delicious(set_bundle) {
    url https://api.del.icio.us/v1/bundles/set
    auth basic
    req_args { bundle: tags: }
    check_result { {[regexp {<result>ok} $result]} {} }
}
set delicious(delete_bundle) {
    url https://api.del.icio.us/v1/bundles/delete
    auth basic
    req_args { bundle: }
    check_result { {[regexp {<result>done} $result]} {} }
}
set delicious(public_posts) {
    url http://feeds.delicious.com/v2/json/%user%/%tags:%
    opt_args { count: }
}
set delicious(modify_post) {
    url https://api.del.icio.us/v1/posts/add
    auth basic
    req_args { post: }
    opt_args { description: extended: tags: dt: shared: }
    check_result { {[regexp {<result code=\"done} $result]} {} }
    result raw
    input_transform {
        set new [dict remove [dict get $query post] hash others meta]
        foreach {from to} {href url tag tags time dt} {
             set v [dict get $new $from]
             set new [dict remove $new $from]
             dict set new $to $v
        }
        dict for {k v} [dict remove $query post] {
            if {$v == ""} {
                set new [dict remove $new $k]
                continue
            }
            if {$k == "dt"} { set v [string trimright $v Z] }
            set new [dict replace $new $k $v]
        }
        return $new
    }
}
rest::create_interface delicious
 
     |