E
E
Enniack2016-02-08 11:53:45
PHP
Enniack, 2016-02-08 11:53:45

How to pass OAUTH2?

I make a request like this:

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_URL, "https://api.shutterstock.com/v2/oauth/authorize?client_id=мой_ид&redirect_uri=\"http://localhost:3000/callback\"&response_type=code&state=demo");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);

$html1 = curl_exec($ch);

echo $html1;

Returns
Moved Temporarily. Redirecting to https://accounts.shutterstock.com/login?next=%2Foa...
Docks:
https://developers.shutterstock.com/guides/authent...
Next should be a redirect to localhost:3000/callback? code=qazwsxedcrfvtgbyhnujm...
From where I extract the code and work on. and there is no redirect to localhost :(
Can anyone tell me what is the reason?
I read about OAUTH2 authorization clients, is it worth trying them
? I have been suffering for several days already.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Justique, 2016-02-08
@Enniack

CURLOPT_FOLLOWLOCATION true

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question