Example of a program that uses the TwitPic library.
Dependencies: EthernetNetIf TwitPic mbed DNSResolver
main.cpp
00001 #include "TwitPic.h" 00002 00003 #define IMAGE_PATH "/local/image.jpg" 00004 00005 //get an api key from twit.pic, put it below 00006 const char twitpic_api_key[] = "PUT_YOUR_TWITPIC_API_KEY_HERE"; 00007 00008 00009 //twitter has a lot more keys you need. get all those and enter them below. 00010 const char consumer_key[] = "PUT_YOUR CONSUMER_KEY_HERE"; 00011 const char consumer_secret[] = "PUT_YOUR_CONSUMER_SECRET_HERE"; 00012 00013 00014 const char access_token[] = "PUT_YOUR_ACCESS_TOKEN_HERE"; 00015 const char access_token_secret[] = "ACCESS_TOKEN_SECRET_HERE"; 00016 00017 int main() { 00018 TwitPic twitpic(twitpic_api_key,consumer_key,consumer_secret,access_token,access_token_secret); 00019 LocalFileSystem local("local"); 00020 EthernetNetIf network; 00021 00022 00023 printf("Setting up network...\n"); 00024 EthernetErr ethErr = network.setup(); 00025 if (ethErr) { 00026 printf("Error %d in network setup.\n", ethErr); 00027 return -1; 00028 } 00029 printf("Network Setup OK\n"); 00030 00031 printf("Opening File...\n"); 00032 FILE *img = fopen(IMAGE_PATH, "r"); 00033 if (img == NULL) { 00034 printf("Error in file open.\n"); 00035 return -1; 00036 } 00037 printf("File open.\n"); 00038 00039 int ret = twitpic.uploadAndPost("What the what?", img); 00040 if (ret < 0) { 00041 printf("Twitpic upload failed with error %i",ret); 00042 return ret; 00043 } 00044 return 0; 00045 }
Generated on Wed Jul 27 2022 20:55:02 by 1.7.2