Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-检索访问令牌-禁用隐式OAuth_Php_Http_Instagram_Access Token_Instagram Api - Fatal编程技术网

PHP-检索访问令牌-禁用隐式OAuth

PHP-检索访问令牌-禁用隐式OAuth,php,http,instagram,access-token,instagram-api,Php,Http,Instagram,Access Token,Instagram Api,我正在使用Instagram Api。 为了检索访问令牌,我使用带有参数“code”的方法。 通过这个代码参数,我可以构建一个url,它将返回访问令牌 例如: https://instagram.com/oauth/authorize/?client_id=CODE_ID&redirect_uri=my-redirect-url&response_type=code 当我通过网络浏览器访问此URL时,在Instagram重定向后,它将返回到我创建的web服务。然后,存储我的访问

我正在使用Instagram Api。 为了检索访问令牌,我使用带有参数“code”的方法。 通过这个代码参数,我可以构建一个url,它将返回访问令牌

例如:

https://instagram.com/oauth/authorize/?client_id=CODE_ID&redirect_uri=my-redirect-url&response_type=code
当我通过网络浏览器访问此URL时,在Instagram重定向后,它将返回到我创建的web服务。然后,存储我的访问令牌

如何在PHP中实现自动化

此示例不起作用:

exec('curl https://instagram.com/oauth/authorize/?client_id=CODE_ID&redirect_uri=my-redirect-url&response_type=code');
我如何处理Instagram的重定向


提前感谢。

由于在生成授权码之前需要明确的用户身份验证,因此无法自动执行此操作。因此,您必须使用PHP重定向:

header('Location: https://instagram.com/oauth/authorize/?client_id=CODE_ID&redirect_uri=my-redirect-url&response_type=code');
让用户在Instagram浏览器中进行身份验证,然后获取Instagram发送到
重定向uri
的代码