Translate

Samstag, 11. Oktober 2014

Mit C++ Status Updates auf Twitter posten


#include <CkHttp.h>
#include <CkHttpRequest.h>
#include <CkHttpResponse.h>

void ChilkatSample(void)
    {
    CkHttp http;

    bool success;

    //  Any string unlocks the component for the 1st 30-days.
    success = http.UnlockComponent("Anything for 30-day trial");
    if (success != true) {
        printf("%s\n",http.lastErrorText());
        return;
    }

    //  Set the login/password for Twitter Authentication:
    http.put_Login("myLogin");
    http.put_Password("myPassword");

    CkHttpRequest req;
    req.AddParam("user","myUsername");
    req.AddParam("status","The text of my status update / tweet");

    CkHttpResponse *response = 0;
    response = http.PostUrlEncoded("http://twitter.com/statuses/update.xml",req);
    if (response == 0 ) {
        printf("%s\n",http.lastErrorText());
    }
    else {
        if (response->get_StatusCode() == 200) {
            printf("Tweet Successful!\n");
        }
        else {
            printf("%s\n",response->bodyStr());
        }

        delete response;
    }


    }

Keine Kommentare:

Kommentar veröffentlichen