[Programming/twit4cpp] - twit4cpp - Twitter API : OAuth 인증 예제
[Programming/twit4cpp] - twit4cpp - 트위터 Twitter API : 타임라인(Timeline) 가져오기 예제
[Programming/twit4cpp] - twit4cpp - 트위터 Twitter API : 다이렉트메시지(DirectMessages) 예제
#include <twit/Twitter.h>
#include <stdio.h>
#include <iostream>
using namespace std;
using namespace Twit;
int main(int argc, char* argv[])
{
/* twit4cpp Sample Application */
try
{
/* customer key와 customer secret은 XAuth사용이 허가된 값을 사용해야합니다. */
string
customerKey("2rBtCAh5o10zMlS2FbRYAA"),
customerSecert("MoZvHvDGbi6zoPu6Q1SZHsalGynP8qWt9dlB1NKlvQg");
string
username,
password;
Twitter twit(customerKey, customerSecert);
cout << "Enter twitter username : ";
cin >> username;
cout << "Enter twitter password : ";
cin >> password;
/***
* 1. access token 요청
*/
string aToken, aSecret;
string screenName;
Value::UniqueID userId;
screenName = twit.XAuth.getAccessToken(username, password, aToken, aSecret, &userId);
printf("ScreenName : %s\n", screenName.c_str());
printf("userId : %s\n", userId.toString().c_str());
printf("AccessToken : %s\n", aToken.c_str());
printf("AccessTokenSecret : %s\n", aSecret.c_str());
}
catch(const Error& e)
{
printf("code : %d\n", e.getCode());
printf("message : %s\n", e.getMessage().c_str());
}
return 0;
}