Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Mar 15, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant