简体   繁体   English

Instagram PHP Laravel访问令牌

[英]Instagram php laravel access token

I was able to get the code from instagram api. 我能够从instagram api中获取代码。 The next step is to post the client_id, client_secret, grant_type, redirect_uri and code to https://api.instagram.com/oauth/access_token as shown below. 下一步是将client_id,client_secret,grant_type,redirect_uri和代码发布到https://api.instagram.com/oauth/access_token ,如下所示。

The instagram API says that "you simply have to POST this code, along with some app identification parameters, to our access_token endpoint." instagram API说:“您只需要将此代码以及一些应用程序标识参数发布到我们的access_token端点即可。”

 curl -F 'client_id=CLIENT_ID' \
    -F 'client_secret=CLIENT_SECRET' \
    -F 'grant_type=authorization_code' \
    -F 'redirect_uri=AUTHORIZATION_REDIRECT_URI' \
    -F 'code=CODE' \
    https://api.instagram.com/oauth/access_token

How can I do this in my laravel controller or php script? 如何在laravel控制器或php脚本中执行此操作? How do I put all these information as a variable and post it to the uri to get back the json object? 我如何将所有这些信息作为变量并将其发布到uri以获取json对象? Thank you 谢谢

using ssh task runner 使用ssh任务运行程序

$commands = ["curl -F 'client_id=CLIENT_ID' \
    -F 'client_secret=CLIENT_SECRET' \
    -F 'grant_type=authorization_code' \
    -F 'redirect_uri=AUTHORIZATION_REDIRECT_URI' \
    -F 'code=CODE' \
    https://api.instagram.com/oauth/access_token"]

//       your command, the output of the command
SSH::run($commands   , function($line)
{
    echo $line.PHP_EOL;
});

OR simply using both php internal functions exec , shell_exec or system 或者简单地使用php内部函数execshell_execsystem


Another approach - in case of you want to keep away of shell commands - is by using guzzle package or internal php cURL library 另一种方法- 如果您想避开shell命令 -通过使用guzzle软件包或内部php cURL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM