Using twitCurl how do I pass parameters to twitter URLs
I need to access the Twitter API for a quick project I am working on and not wishing to get too tied up in learning the API I thought twitCurl would be the ideal solution.
At the moment, all I need to do is开发者_如何学Python get the latest mentions for a Twitter user, which twitCurl can do very easily and takes care of all the oAuth stuff into the bargain.
But I now want to use the 'since_id' parameter in my call to the API. I can see no way to do this with twitCurl, and in fact there seems to be no way to pass parameters to many of the twitCurl calls. Am I missing something or is this something seriously lacking from twitCurl?
If this is not possible then can someone suggest and alternative C++ wrapper for the Twitter API.
Thanks for reading.
I don't like to answer my own question but I have fixed it and just in case anyone else has the same problem I will document it here.
I modified the twitCurl code to add an extra parameter, a string to represent the 'since_id'. It was really straightforward in the end and I have submitted the changes to the twitCurl developers. Here is my diff of the changes if you can't wait:
Index: twitcurl.cpp =================================================================== --- twitcurl.cpp (revision 25) +++ twitcurl.cpp (working copy) @@ -474,19 +474,28 @@ * * @description: method to get mentions * -* @input: none +* @input: sinceId - since_id in string format * * @output: true if GET is success, otherwise false. This does not check http * response by twitter. Use getLastWebResponse() for that. * *--*/ -bool twitCurl::mentionsGet() +bool twitCurl::mentionsGet( std::string sinceId ) { bool retVal = false; if( isCurlInit() ) { + /* Prepare URL */ + std::string buildUrl( "" ); + buildUrl = twitterDefaults::TWITCURL_MENTIONS_URL; + if( sinceId.length() ) + { + buildUrl.append( twitCurlDefaults::TWITCURL_SINCEID.c_str() ); + buildUrl.append( sinceId.c_str() ); + } + /* Perform GET */ - retVal = performGet( twitterDefaults::TWITCURL_MENTIONS_URL ); + retVal = performGet( buildUrl ); } return retVal; } Index: twitcurl.h =================================================================== --- twitcurl.h (revision 25) +++ twitcurl.h (working copy) @@ -24,6 +24,7 @@ const std::string TWITCURL_EXTENSIONFORMAT = ".xml"; const std::string TWITCURL_TARGETSCREENNAME = "? target_screen_name="; const std::string TWITCURL_TARGETUSERID = "?target_id="; + const std::string TWITCURL_SINCEID = "?since_id="; }; /* Default twitter URLs */ @@ -123,7 +124,7 @@ bool timelineFriendsGet(); bool timelineUserGet( std::string userInfo = "" /* in */, bool isUserId = false /* in */ ); bool featuredUsersGet(); - bool mentionsGet(); + bool mentionsGet( std::string sinceId = "" ); /* Twitter user APIs */ bool userGet( std::string& userInfo /* in */, bool isUserId = false /* in */ );
精彩评论