Example of a program that uses the TwitPic library.

Dependencies:   EthernetNetIf TwitPic mbed DNSResolver

main.cpp

Committer:
treebykooba
Date:
2011-02-26
Revision:
0:4a6b01bf147d
Child:
1:44a07cd54a87

File content as of revision 0:4a6b01bf147d:

#include "TwitPic.h"

#define IMAGE_PATH "/local/image.jpg"

const char twitpic_api_key[]    = "31c45945be2638bydjua1c4d4278d9602"; 

const char consumer_key[]        = "Hl1fObuUdobieyHZtsw52qg";  
const char consumer_secret[]     = "7CmMt8nTTYKM2F6nPMSiC2DqFPYmKDZOUc3lvWIJsFk"; 


const char access_token[]        = "8839572789-uUjbndiYi2EOutUvsMYkJNcK9JtRbWhU"; 
const char access_token_secret[] = "kLXd6xmIkdTS098Jb97EOBHCZkIyOZCxlYQTdug"; 

int main() {
    TwitPic twitpic(twitpic_api_key,consumer_key,consumer_secret,access_token,access_token_secret);  
    LocalFileSystem local("local");
    EthernetNetIf network;
    
    
    printf("Setting up network...\n");
    EthernetErr ethErr = network.setup();
    if (ethErr) {
        printf("Error %d in network setup.\n", ethErr);
        return -1;
    }
    printf("Network Setup OK\n");

    printf("Opening File...\n");
    FILE *img = fopen(IMAGE_PATH, "r");
    if (img == NULL) {
        printf("Error in file open.\n");
        return -1;
    }
    printf("File open.\n");
   
    int ret = twitpic.uploadAndPost("What the what?", img);
    if (ret < 0) {
        printf("Twitpic upload failed with error %i",ret);
        return ret;
    }
    return 0;
}