Use this library to upload images to twitpic.com. The library creates and uses its own TCPSocket. Requires EthernetNetIf and DNSResolver. (this library actually designed by a friend of mine, novachild, with no mbed license of his own.)
TwitPic.h@0:e8e33b39c3cc, 2011-02-26 (annotated)
- Committer:
- treebykooba
- Date:
- Sat Feb 26 20:07:01 2011 +0000
- Revision:
- 0:e8e33b39c3cc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
treebykooba | 0:e8e33b39c3cc | 1 | /* |
treebykooba | 0:e8e33b39c3cc | 2 | TwitPic.h - TwitPic Image Uploader for mbed |
treebykooba | 0:e8e33b39c3cc | 3 | Copyright (c) novachild 2011. All rights reserved. |
treebykooba | 0:e8e33b39c3cc | 4 | |
treebykooba | 0:e8e33b39c3cc | 5 | This library is distributed in the hope that it will be useful, |
treebykooba | 0:e8e33b39c3cc | 6 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
treebykooba | 0:e8e33b39c3cc | 7 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
treebykooba | 0:e8e33b39c3cc | 8 | |
treebykooba | 0:e8e33b39c3cc | 9 | REQUIRES: EthernetNetIf, DNSResolver, some sort of file access (SD, local, etc) |
treebykooba | 0:e8e33b39c3cc | 10 | |
treebykooba | 0:e8e33b39c3cc | 11 | */ |
treebykooba | 0:e8e33b39c3cc | 12 | |
treebykooba | 0:e8e33b39c3cc | 13 | #ifndef TwitPic_h |
treebykooba | 0:e8e33b39c3cc | 14 | #define TwitPic_h |
treebykooba | 0:e8e33b39c3cc | 15 | |
treebykooba | 0:e8e33b39c3cc | 16 | #include "mbed.h" |
treebykooba | 0:e8e33b39c3cc | 17 | #include "EthernetNetIf.h" |
treebykooba | 0:e8e33b39c3cc | 18 | #include "TCPSocket.h" |
treebykooba | 0:e8e33b39c3cc | 19 | #include "host.h" |
treebykooba | 0:e8e33b39c3cc | 20 | #include "ipaddr.h" |
treebykooba | 0:e8e33b39c3cc | 21 | #include "dnsresolve.h" |
treebykooba | 0:e8e33b39c3cc | 22 | |
treebykooba | 0:e8e33b39c3cc | 23 | class TwitPic { |
treebykooba | 0:e8e33b39c3cc | 24 | public: |
treebykooba | 0:e8e33b39c3cc | 25 | TwitPic(const char *twitpic_api_key, const char *consumer_key, const char *consumer_secret, const char *access_token, const char *access_token_secret); |
treebykooba | 0:e8e33b39c3cc | 26 | int upload(const char *message, |
treebykooba | 0:e8e33b39c3cc | 27 | FILE *img, |
treebykooba | 0:e8e33b39c3cc | 28 | bool toPost = false); |
treebykooba | 0:e8e33b39c3cc | 29 | |
treebykooba | 0:e8e33b39c3cc | 30 | int uploadAndPost(const char *message, |
treebykooba | 0:e8e33b39c3cc | 31 | FILE *imgFile); |
treebykooba | 0:e8e33b39c3cc | 32 | |
treebykooba | 0:e8e33b39c3cc | 33 | private: |
treebykooba | 0:e8e33b39c3cc | 34 | Host server; |
treebykooba | 0:e8e33b39c3cc | 35 | TCPSocket socket; |
treebykooba | 0:e8e33b39c3cc | 36 | |
treebykooba | 0:e8e33b39c3cc | 37 | |
treebykooba | 0:e8e33b39c3cc | 38 | void handleTCPSocketEvents(TCPSocketEvent ev); |
treebykooba | 0:e8e33b39c3cc | 39 | |
treebykooba | 0:e8e33b39c3cc | 40 | void sendHeaders(); |
treebykooba | 0:e8e33b39c3cc | 41 | void sendParameters(); |
treebykooba | 0:e8e33b39c3cc | 42 | void sendImageData(); |
treebykooba | 0:e8e33b39c3cc | 43 | void sendFooter(); |
treebykooba | 0:e8e33b39c3cc | 44 | void sendNextChunk(); |
treebykooba | 0:e8e33b39c3cc | 45 | |
treebykooba | 0:e8e33b39c3cc | 46 | void getResponse(); |
treebykooba | 0:e8e33b39c3cc | 47 | void flushResponse(); |
treebykooba | 0:e8e33b39c3cc | 48 | |
treebykooba | 0:e8e33b39c3cc | 49 | }; |
treebykooba | 0:e8e33b39c3cc | 50 | |
treebykooba | 0:e8e33b39c3cc | 51 | |
treebykooba | 0:e8e33b39c3cc | 52 | #endif |