-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.cpp
61 lines (52 loc) · 2.08 KB
/
model.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <twitcurl.h>
#include <tensorflow/c/c_api.h>
#include <stdio.h>
#include <iostream>
twitCurl *oAuthFlow() {
twitCurl twit;
std::string replyMsg;
std::string myOAuthAccessTokenKey("");
std::string myOAuthAccessTokenSecret("");
char tmpBuf[1024];
memset( tmpBuf, 0, 1024 );
twit.setTwitterUsername(std::getenv("TWITTER_USERNAME"));
twit.setTwitterPassword(std::getenv("TWITTER_PASSWORD"));
/* OAuth flow begins */
/* Step 0: Set OAuth related params. These are got by registering your app at twitter.com */
printf("Beginning auth with %s, %s\n", std::getenv("TWITTER_API_KEY"), std::getenv("TWITTER_API_SECRET"));
printf("Beginning auth with %s, %s\n", std::getenv("TWITTER_API_KEY"), std::getenv("TWITTER_API_SECRET"));
twit.getOAuth().setConsumerKey(std::getenv("TWITTER_API_KEY"));
twit.getOAuth().setConsumerSecret(std::getenv("TWITTER_API_SECRET"));
/* Step 2: Get request token key and secret */
std::string authUrl;
twit.oAuthRequestToken( authUrl );
printf("Cool\n");
/* Step 3: Get PIN */
// twit.oAuthHandlePIN(authUrl);
/* Step 4: Exchange request token with access token */
// twit.oAuthAccessToken();
// /* Step 5: Now, save this access token key and secret for future use without PIN */
// twit.getOAuth().getOAuthTokenKey(myOAuthAccessTokenKey);
// twit.getOAuth().getOAuthTokenSecret(myOAuthAccessTokenSecret);
// /* Check reply */
// /* Account credentials verification */
// if(twit.accountVerifyCredGet()) {
// twit.getLastWebResponse(replyMsg);
// printf("\nmodel::twitCurl::accountVerifyCredGet web response:\n%s\n", replyMsg.c_str());
// }
// else {
// twit.getLastCurlError(replyMsg);
// printf("\nmodel::twitCurl::accountVerifyCredGet error:\n%s\n", replyMsg.c_str());
// }
return NULL;
}
int main() {
FILE *env = fopen(".env", "r");
if (env == NULL) {
printf("Please store the following environment variables in a .env file!\n");
printf("[TWITTER_USERNAME, TWITTER_PASSWORD, TWITTER_API_KEY, TWITTER_API_SECRET]\n");
exit(1);
}
twitCurl* twit = oAuthFlow();
printf("Hello from TensorFlow C library version %s\n", TF_Version());
}