C++ native use of Twitter REST API using HTTP Request -


i've been trying access twitter api in order search tweet particular hashtag. since twitter api 1.1 authentication needed so. application written in c++ , not use additionnal lib curl. here's code i've been using :

std::string request="get /1.1/search/tweets.json?q=%23helloworld http/1.1\r\n" "x-hostcommonname: api.twitter.com\r\n" "authorization: oauth " "oauth_consumer_key=\"xxxxxxxxxxxx\", oauth_signature_method=\"hmac-sha1\", oauth_timestamp=\""+imtime.str()+"\", oauth_nonce=\""+imtime.str()+"\", oauth_version=\"1.0\", oauth_token=\"xxxxxxxxxxxxxxxx\", oauth_signature=\"xxxxxxxxxx\"\r\n" "host: api.twitter.com\r\n" "x-target-uri: https://api.twitter.com\r\n" "connection: close\r\n\r\n"; socket sock=socket(af_inet,sock_stream,0); if (sock==invalid_socket) {return 0; //error} sockaddr_in sin; struct in_addr addr2; struct hostent *host_adresse = gethostbyname("api.twitter.com"); if ((host_adresse)&&(host_adresse->h_addrtype==af_inet)) memcpy(&addr2,host_adresse->h_addr,sizeof(struct in_addr)); sin.sin_addr.s_addr=addr2.s_addr; sin.sin_family=af_inet; sin.sin_port=htons(80); int recsize=(int) sizeof sin; if (connect(sock,(sockaddr*)&sin,recsize)==socket_error) {return 0; //error} send(sock,request.c_str(),request.length(),0); 

but receive error : ssl required (code: 92) can't manage find out how use ssl http requests. know it's quite complicated , easier use lib, i'd code working somehow.


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -