c:twitter.awk
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
c:twitter.awk [2011/07/24 21:23] – source header neutronscott | c:twitter.awk [2023/11/04 22:30] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Twitter.awk ====== | ====== Twitter.awk ====== | ||
- | [[http:// | + | [[http:// |
- | ===== Programming it ===== | + | ===== Challenges |
- | The latest challenge was messing with unicode/ | + | Starting from the beginning, and ending at the latest.. |
- | JSON will express this euro as \u20ac, I have to convert | + | ==== JSON ==== |
+ | awk doesn' | ||
- | I think it's good now. I'd still like to re-do the JSON parser. It goes char-by-char while somewhat remembering the state. It does it this way because | + | ==== OAuth ==== |
+ | Twitter requires HMAC-SHA1. This isn't hard with a pipe to openssl and base64. The hardest part to grasp is what parameters to send and when.. Once you have that figured out, you'll get denied again because | ||
- | ===== Source ===== | + | ==== Unicode |
+ | This challenge was revisited a couple times. I now know what Unicode and UTF-8 actually are! :) ASCII is define as first 127 (bit 7 is 0) to keep backward compat with the way things were. If bit 7 is 1, it is UTF-8. UTF-8 is a variable byte-width character, and uses a bitmap to determine how many following bytes are used. For example the Euro currency symbol is U+20AC and once it is encoded it is " | ||
- | The code is viewable [[http://scottn.us/code/view.php?f=twitter.awk|here]]. | + | JSON will express this Euro as \u20ac in a string. I first have to convert to UTF-8 to display to terminal. Then I have to URL encode it to re-send to Twitter. In awk, sprintf(" |
+ | |||
+ | ==== HMAC-SHA1 ==== | ||
+ | I wanted to drop dependancy on OpenSSL CLI, so I wrote HMAC-SHA1 routine in awk using binary strings. :) | ||
+ | |||
+ | IT WORKS! It's not for hashing a ton of files, just for OAuth header so speed is like... pfft whatever. | ||
+ | |||
+ | It was mostly creating functions that did binary operations using strings. Then a direct implement of the wikipedia pseudo-code, but I had to refer to the actual FIPS specification to realize some things. It almost worked on the first go. Then a bug with padding (oops, pad -17 bytes? how'd I end up with that math hah). | ||
+ | |||
+ | Then a quick base64(), which wasn't hard to debug. I just was missing ' | ||
+ | |||
+ | ===== Source ===== | ||
+ | Decided to start using my github account and have been pushing the code to: http:// |
c/twitter.awk.1311542607.txt.gz · Last modified: 2023/11/04 22:29 (external edit)