Anyone have AppData update working over REST?

0 views
Skip to first unread message

scott persinger

unread,
Jul 22, 2008, 12:27:48 PM7/22/08
to Spacer: The MySpace Platform Ruby Client
Can anyone post working code for updating AppData over REST? I was
hoping this would be a small addition to the spacer library, but it
looks like the additional logic for sending a PUT is stretching the
boundaries of what the underlying oauth-ruby library supports.

--Scott

findchris

unread,
Jul 22, 2008, 1:45:19 PM7/22/08
to Spacer: The MySpace Platform Ruby Client
Hi there.

I patched did the following to add this functionality:
Add to myspace/object.rb:

def put(params,optParams=nil,data="")
path = self.build_request(params,optParams)

MySpace.connection.put(path, data) do |resp|
puts "MySpace response: #{resp.inspect}" #DEBUG
end
end

Add to myspace/connection.rb:
def put(path="/",data="",headers={},content_type="application/x-www-
form-urlencoded")
connect if !@http

req = HTTP::Put.new(path,headers)
req.body = data
req.content_type = content_type

req.oauth!(@http,consumer,nil,@oauthOptions)
if block_given?
yield @http.request(req)
else
@http.request(req)
end

@http.finish if @http.started?
end

Hope that helps!
-Chris

findchris

unread,
Jul 22, 2008, 1:51:42 PM7/22/08
to Spacer: The MySpace Platform Ruby Client
Forgot one part:
class MySpace::AppData < MySpace::Object
@pathFormat = "/users/%s/appdata".freeze
@numParams = 1.freeze
@dataType = "Hash".freeze

attr_accessor :userid
attr_accessor :keyvaluecollection
end


Then call it like:
MySpace::AppData.put(myspace_user_id.to_s, nil, app_data)

Took me a little while to figure this out. If it works for you would
you mind recommending me here (http://workingwithrails.com/person/
11433-chris-johnson)?

Thanks,
Chris

On Jul 22, 9:27 am, scott persinger <sc...@remixation.com> wrote:

scott persinger

unread,
Jul 22, 2008, 2:03:10 PM7/22/08
to Spacer: The MySpace Platform Ruby Client
Chris,

Are we talking about the same library? I'm using Spacer, which doesn't
define any 'Myspace' module.

Is this patch for the myspace-ruby library?

--Scott

scott persinger

unread,
Jul 22, 2008, 2:10:10 PM7/22/08
to Spacer: The MySpace Platform Ruby Client
Just a note, I've got something working with Spacer now. The post is
here:

http://groups.google.com/group/spacer-ruby/browse_thread/thread/4de1a93f0cb8584d

findchris

unread,
Jul 22, 2008, 2:36:43 PM7/22/08
to Spacer: The MySpace Platform Ruby Client
oops, sorry Scott.
My code was a patch to the official MySpace Ruby library.
Good work on patching spacer. You plan to submit the patch to spacer
(or fork it on github)?

-Chris
Reply all
Reply to author
Forward
0 new messages