Welcome Developers!

in

Welcome!

in

Timeout sending App Notification

Last post 06-09-2009 9:36 PM by myspace PPI. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 06-09-2009 8:17 PM

    Timeout sending App Notification

    I'm trying to use the server-to-server app notification, but I keep getting a 500 read timeout.
    I've verified that by base string and signature match what's generated by the OAuth testing tool, and I've bumped up the read timeout to 60 secs.

    I'm use perl's Net::OAth, here's my code:

    my $request = Net::OAuth->request('consumer')->new(
            'consumer_key'        => <MyKey>,
            'consumer_secret'    => <MySecret>,
            'request_url'        => 'http://api.myspace.com/v1/applications/<AppID>/notifications',
            'request_method'    => 'POST',
            'signature_method'    => 'HMAC-SHA1',
            'timestamp'         => time,
            'nonce'             => time.'-1',
            'version'            => '1.0',
           'extra_params'        => {
                    'recipients'        => <TestUserID>,
                    'templateParameters' => '{"content":"test1"}',
            },
        );
        $request->sign;
            
        my $ua = LWP::UserAgent->new;
        $ua->timeout(60);
        my $res = $ua->request(POST $request->to_url);

     Is there some kind of outage, or maybe some security setting I'm not aware of?

  • 06-09-2009 9:36 PM In reply to

    Re: Timeout sending App Notification

    Figured it out... the extra_params is needed to genereate the secret, but should not be used in the URL and put in the post body instead, he following is corrected code for those of the Perl persuasion:

    my $extraparams = {
                    'recipients'        => <TestUserID>,
                    'templateParameters' => '{"content":"test1"}',
            };
    my $request = Net::OAuth->request('consumer')->new(
            'consumer_key'        => <MyKey>,
            'consumer_secret'    => <MySecret>,
            'request_url'        => 'http://api.myspace.com/v1/applications/<AppID>/notifications',
            'request_method'    => 'POST',
            'signature_method'    => 'HMAC-SHA1',
            'timestamp'         => time,
            'nonce'             => time.'-1',
            'version'            => '1.0',
           'extra_params'        => $extraparams,
        );
        $request->sign;
            
        my $ua = LWP::UserAgent->new;
        $ua->timeout(60);
        $request->extra_params('');
        my $res = $ua->post($request->to_url, $extraparams);

Page 1 of 1 (2 items)