tags:

views:

27

answers:

1

Hi,

I'm having a strange problem using PHP's OAuth PECL library - I seem to be unable to get it to make requests via GET.

I'm using v1.0.0.

This is the request:

$oauth = new OAuth(
    $network->get_consumer_key(),
    $network->get_consumer_secret(),
    OAUTH_SIG_METHOD_HMACSHA1,
    OAUTH_AUTH_TYPE_FORM
);
$oa->enableDebug();
$oauth->setToken('<token>', '<secret token>');
$oauth->fetch('<protected url>', array(), OAUTH_HTTP_METHOD_GET, array("User-Agent" => "pecl/oauth"));

Yet the result I get is:

[debugInfo] => Array
                (
                    [sbs] => 
                    [headers_sent] => POST  HTTP/1.1
...

... it uses POST every time. The OAUTH_HTTP_METHOD_GET constant is set to the string GET.

Any ideas?

A: 

I believe that OAUTH_AUTH_TYPE_FORM in your constructor forces it to do a POST, and not a GET. See here for more info: http://www.php.net/manual/en/oauth.setauthtype.php

Mike Sherov
Excellent, thanks. I'd tried removing the OAUTH_AUTH_TYPE_FORM but hadn't tried setting it to something else. OAUTH_AUTH_TYPE_URI makes it work.
Outspaced
Yeah, the default value is OAUTH_AUTH_TYPE_AUTHORIZATION, so that wouldn't work either. OAUTH_AUTH_TYPE_URI effectively says "everything you need is in the URI".
Mike Sherov