PHP OAuth Uncaught exception 'OAuthException'

I'm trying to connect to this system's API:

The initial dus toff is okay, the user is presented with a login screen and asked to confirm they want to grant access, after they are pushed back to a callback handler

function callback($args, &$request) {
		$article_id = clean_string(array_shift($args));
		$this->validate($request, $article_id, 4);

		$consumer_key = Config::getVar('general', 'figshare_consumer_key');
		$consumer_secret = Config::getVar('general', 'figshare_consumer_secret');

		$oauth = new OAuth($consumer_key, $consumer_secret);
		$oauth->setToken($_SESSION['req_token'], $_SESSION['req_secret']);

		$response = $oauth->getAccessToken(
			'' . $_GET["oauth_verifier"]


		echo 'token:' . $response['oauth_token'];

		$_SESSION['oauth_token'] = $response['oauth_token'];
		$_SESSION['oauth_token_secret'] = $response['oauth_token_secret'];

		//header('Location:' . $article_id);

Open in new window

The req_token and req_secret are okay, they get returned okay and are set. But when I run the getAccessToken I get the following error message:

Uncaught exception 'OAuthException' with message 'Invalid auth/bad request (got a 405, expected HTTP/1.1 20X or a redirect)'

If i attempt to add the oauth_verifier as part of an array like:

$response = $oauth->getAccessToken(
			array('oauth_verifier' => $_GET["oauth_verifier"])

Open in new window

I get the same error.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Have a look at their PHP example.  It shows them using a different OAuth method, which makes sense because HTTP 405 means "Method not allowed."
up-techAuthor Commented:
Turns out you need to set getAccessToken to pass a post using:

getAccessToken($url, null,null, 'POST');

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.