Example of a program that uses the TwitPic library.
Dependencies: EthernetNetIf TwitPic mbed DNSResolver
main.cpp@0:4a6b01bf147d, 2011-02-26 (annotated)
- Committer:
- treebykooba
- Date:
- Sat Feb 26 20:10:39 2011 +0000
- Revision:
- 0:4a6b01bf147d
- Child:
- 1:44a07cd54a87
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
treebykooba | 0:4a6b01bf147d | 1 | #include "TwitPic.h" |
treebykooba | 0:4a6b01bf147d | 2 | |
treebykooba | 0:4a6b01bf147d | 3 | #define IMAGE_PATH "/local/image.jpg" |
treebykooba | 0:4a6b01bf147d | 4 | |
treebykooba | 0:4a6b01bf147d | 5 | const char twitpic_api_key[] = "31c45945be2638bydjua1c4d4278d9602"; |
treebykooba | 0:4a6b01bf147d | 6 | |
treebykooba | 0:4a6b01bf147d | 7 | const char consumer_key[] = "Hl1fObuUdobieyHZtsw52qg"; |
treebykooba | 0:4a6b01bf147d | 8 | const char consumer_secret[] = "7CmMt8nTTYKM2F6nPMSiC2DqFPYmKDZOUc3lvWIJsFk"; |
treebykooba | 0:4a6b01bf147d | 9 | |
treebykooba | 0:4a6b01bf147d | 10 | |
treebykooba | 0:4a6b01bf147d | 11 | const char access_token[] = "8839572789-uUjbndiYi2EOutUvsMYkJNcK9JtRbWhU"; |
treebykooba | 0:4a6b01bf147d | 12 | const char access_token_secret[] = "kLXd6xmIkdTS098Jb97EOBHCZkIyOZCxlYQTdug"; |
treebykooba | 0:4a6b01bf147d | 13 | |
treebykooba | 0:4a6b01bf147d | 14 | int main() { |
treebykooba | 0:4a6b01bf147d | 15 | TwitPic twitpic(twitpic_api_key,consumer_key,consumer_secret,access_token,access_token_secret); |
treebykooba | 0:4a6b01bf147d | 16 | LocalFileSystem local("local"); |
treebykooba | 0:4a6b01bf147d | 17 | EthernetNetIf network; |
treebykooba | 0:4a6b01bf147d | 18 | |
treebykooba | 0:4a6b01bf147d | 19 | |
treebykooba | 0:4a6b01bf147d | 20 | printf("Setting up network...\n"); |
treebykooba | 0:4a6b01bf147d | 21 | EthernetErr ethErr = network.setup(); |
treebykooba | 0:4a6b01bf147d | 22 | if (ethErr) { |
treebykooba | 0:4a6b01bf147d | 23 | printf("Error %d in network setup.\n", ethErr); |
treebykooba | 0:4a6b01bf147d | 24 | return -1; |
treebykooba | 0:4a6b01bf147d | 25 | } |
treebykooba | 0:4a6b01bf147d | 26 | printf("Network Setup OK\n"); |
treebykooba | 0:4a6b01bf147d | 27 | |
treebykooba | 0:4a6b01bf147d | 28 | printf("Opening File...\n"); |
treebykooba | 0:4a6b01bf147d | 29 | FILE *img = fopen(IMAGE_PATH, "r"); |
treebykooba | 0:4a6b01bf147d | 30 | if (img == NULL) { |
treebykooba | 0:4a6b01bf147d | 31 | printf("Error in file open.\n"); |
treebykooba | 0:4a6b01bf147d | 32 | return -1; |
treebykooba | 0:4a6b01bf147d | 33 | } |
treebykooba | 0:4a6b01bf147d | 34 | printf("File open.\n"); |
treebykooba | 0:4a6b01bf147d | 35 | |
treebykooba | 0:4a6b01bf147d | 36 | int ret = twitpic.uploadAndPost("What the what?", img); |
treebykooba | 0:4a6b01bf147d | 37 | if (ret < 0) { |
treebykooba | 0:4a6b01bf147d | 38 | printf("Twitpic upload failed with error %i",ret); |
treebykooba | 0:4a6b01bf147d | 39 | return ret; |
treebykooba | 0:4a6b01bf147d | 40 | } |
treebykooba | 0:4a6b01bf147d | 41 | return 0; |
treebykooba | 0:4a6b01bf147d | 42 | } |