codeon / twitcurl

Automatically exported from code.google.com/p/twitcurl
1 stars 0 forks source link

statusDestroyById( std::string& statusId ) does not create correctly formatted URL #32

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Call statusDestroyById( std::string& statusId )
2.
3.

What is the expected output? What do you see instead?
Confirmation or error associated with the destruction of a status.

What version of the product are you using? On what operating system?
Latest as of 5/4/2012.

Please provide any additional information below.

Here is the fix, a colon ':' must be added to the buildUrl:

bool twitCurl::statusDestroyById( std::string& statusId )
{
   bool retVal = false;
   if ( statusId.length() )
   {
      /* Prepare URL */
      std::string buildUrl = twitterDefaults::TWITCURL_STATUDESTROY_URL + twitCurlDefaults::TWITCURL_COLON + statusId +
                             twitCurlDefaults::TWITCURL_EXTENSIONFORMATS[m_eApiFormatType];

      /* Perform DELETE */
      retVal = performDelete( buildUrl );
   }
   return retVal;
}

Original issue reported on code.google.com by greggw...@gmail.com on 4 May 2012 at 5:10

GoogleCodeExporter commented 8 years ago
Interestingly, it's working without semi colon for me! And, another thing to 
note is we're using DELETE whereas twitter API page says POST.

Original comment by swatkat....@gmail.com on 3 Jun 2012 at 9:34

GoogleCodeExporter commented 8 years ago
Even if this is an old thread, i can't delete tweets still today. i tried first 
this:
bool twitCurl::statusDestroyById( std::string& statusId )
{
    if( statusId.empty() )
    {
        return false;
    }
    /* Prepare URL */
    std::string buildUrl = twitCurlDefaults::TWITCURL_PROTOCOLS[m_eProtocolType] +
                           twitterDefaults::TWITCURL_STATUDESTROY_URL
             + twitCurlDefaults::TWITCURL_COLON // added by me
             + statusId +
                       twitCurlDefaults::TWITCURL_EXTENSIONFORMATS[m_eApiFormatType];

    /* Perform DELETE */
    return performDelete( buildUrl );
}

and i get "{"errors":[{"message":"Sorry, that page does not exist","code":34}]}"
when i remove twitCurlDefaults::TWITCURL_PROTOCOLS (what seems to be similiar 
to your solution) or twitCurlDefaults::TWITCURL_COLON or both i get 
"{"errors":[{"message":"Could not authenticate you","code":32}]}". And if i 
replace performDelete by performPost what should be right according to REST API 
i get bad request errors. Any ideas?
PS: Maybe i haven't got enough oAuth knowledge, do i have to authorize my app 
in some kind for every delete operation or is this done automatically by 
twitcurl? (So if you ask: Yes i did authorize my app at twitter and in my 
account, because i can successfully post tweets and get my user_timeline, but 
just cannot delete tweets)

Original comment by igottafa...@web.de on 14 Oct 2014 at 1:46

GoogleCodeExporter commented 8 years ago
if anyone is still interested in this, i solved my problem after trial and 
error with this method:

bool twitCurl::statusDestroyById( std::string& statusId )
{
    if( statusId.empty() )
    {
        return false;
    }

    std::string msgToPost = "id=" + statusId;

    /* Prepare URL */
    std::string buildUrl = twitCurlDefaults::TWITCURL_PROTOCOLS[m_eProtocolType] +
                           twitterDefaults::TWITCURL_STATUDESTROY_URL
            //+ twitCurlDefaults::TWITCURL_COLON    // not added by me
            + statusId +
                        twitCurlDefaults::TWITCURL_EXTENSIONFORMATS[m_eApiFormatType];

    /* Perform POST */
    return performPost( buildUrl, msgToPost );
}

I think this results in a request like this:
POST https://api.twitter.com/1.1/statuses/destroy/12345678.json?id=12345678
what seems to be redundant and not like in the documentation (which says to use 
a colon first but has none in the example 
https://dev.twitter.com/rest/reference/post/statuses/destroy/%3Aid )

Original comment by igottafa...@web.de on 20 Oct 2014 at 1:07

GoogleCodeExporter commented 8 years ago
I tried using the code above and still doesn't work. Either using performPost 
and performDelete it still gives me the same This method requires a POST error 
and the tweet is never deleted.. Help :(

Original comment by lazzari....@gmail.com on 13 Apr 2015 at 6:17