Trying to trouble shoot DELETE list members with the Twitter gem.

1 view
Skip to first unread message

Michael

unread,
Nov 28, 2009, 12:13:00 AM11/28/09
to Twitter Development Talk
I know that i should post on the Twitter gem group(and i have) but
that place is dead and also i think my problem is not with the gem but
understanding how the oauth and REST works. I could be looking down
the wrong path tho seeing as how i kinda feel like Alice down the
rabbit hole.

Everything dealing with lists works on the twitter gem but one thing
and that's "list_remove_user" which is using the DELETE list members
API.

Now when i use it as planned i get this error.

Twitter::RateLimitExceeded: (400): Bad Request - You must specify a
member

Which is the same error you get if you use the api via curl and leave
off the id

http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-DELETE-list-members

It has nothing to do with the rate limit. twitter gem just returns all
400's as a ratelimitexceded. There is no rate limit for adding and
removing list items and also my account is whitelisted.

Then i moved on and noticed that the delete method was only passing
the uri and header options meanwhile post and put had an extra body
option.

def perform_post
send(:post, uri, options[:body], options[:headers])
end

def perform_delete
send(:delete, uri, options[:headers])
end

From that i assumed that the id that gets passed for the users id must
be inside of the options[:body] and that's why twitter was telling me
"You must specify a member"

When oauth gem creates the url's to query it does it like so and once
again they do not include "body"

def post(path, body = '', headers = {})
request(:post, path, body, headers)
end

def delete(path, headers = {})
request(:delete, path, headers)
end

But that all blows up when i add "body" to delete.

So after all of this i guess what I'm wondering is.. is there
something to do with oauth and REST that will not let you pass along
extra params and do i need to look into using a POST method and
passing _method=DELETE.

I have not tried that yet because i have no idea how to attempt that
in the confines of ruby using oauth. thanks for any help, this is
driving me nuts.

Mike.


Michael

unread,
Nov 28, 2009, 1:20:42 PM11/28/09
to Twitter Development Talk
I have given up with trying to make it work with DELETE and tired
sending "_method=DELETE" along with the body.. no success. i get
Unauthorized - Incorrect signature

Any ideas?

On Nov 28, 12:13 am, Michael <magic6...@gmail.com> wrote:
> I know that i should post on the Twitter gem group(and i have) but
> that place is dead and also i think my problem is not with the gem but
> understanding how the oauth and REST works. I could be looking down
> the wrong path tho seeing as how i kinda feel like Alice down the
> rabbit hole.
>
> Everything dealing with lists works on the twitter gem but one thing
> and that's "list_remove_user" which is using the DELETE list members
> API.
>
> Now when i use it as planned i get this error.
>
> Twitter::RateLimitExceeded: (400): Bad Request - You must specify a
> member
>
> Which is the same error you get if you use the api via curl and leave
> off the id
>
> http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-DELETE-list-mem...

Mark McBride

unread,
Nov 28, 2009, 4:26:40 PM11/28/09
to twitter-deve...@googlegroups.com
This is the twitter gem at http://github.com/jnunemaker/twitter? The
problem seems to be that the list_remove_member in base.rb is trying
to pass parameters in with :body in the last hash

def list_remove_member(list_owner_username, slug, id)
perform_delete("/#{list_owner_username}/#{slug}/members.json",
:body => {:id => id})
end

However perform_delete in request.rb completely ignores this option

def perform_delete
send(:delete, uri, options[:headers])
end

You might try adding :headers => {:_method => "DELETE"} to your call,
but the best path seems to be to get the gem fixed up.

---Mark

Mark McBride

unread,
Nov 28, 2009, 4:53:31 PM11/28/09
to twitter-deve...@googlegroups.com
Actually, adding it to :headers isn't going to do what you want at
all. Best bet seems to be to patch the gem to issue a POST request
along with _method = DELETE

---Mark

Michael

unread,
Nov 29, 2009, 11:04:10 AM11/29/09
to Twitter Development Talk
Hey mark thanks for the reply. I'm going to give it a shot today

On Nov 28, 4:53 pm, Mark McBride <mmcbr...@twitter.com> wrote:
> Actually, adding it to :headers isn't going to do what you want at
> all.  Best bet seems to be to patch the gem to issue a POST request
> along with _method = DELETE
>
>    ---Mark
>
> On Sat, Nov 28, 2009 at 1:26 PM, Mark McBride <mmcbr...@twitter.com> wrote:
> > This is the twitter gem athttp://github.com/jnunemaker/twitter? The
> > problem seems to be that the list_remove_member in base.rb is trying
> > to pass parameters in with :body in the last hash
>
> >    def list_remove_member(list_owner_username, slug, id)
> >      perform_delete("/#{list_owner_username}/#{slug}/members.json",
> > :body => {:id => id})
> >    end
>
> > However perform_delete in request.rb completely ignores this option
>
> >      def perform_delete
> >        send(:delete, uri, options[:headers])
> >      end
>
> > You might try adding :headers => {:_method => "DELETE"} to your call,
> > but the best path seems to be to get the gem fixed up.
>
> >   ---Mark
>

Michael

unread,
Nov 29, 2009, 3:15:03 PM11/29/09
to Twitter Development Talk
If anyone is still having this problem you should know pengwynn
patched this today in 0.7.7
http://github.com/jnunemaker/twitter
Reply all
Reply to author
Forward
0 new messages