Instagram php laravel访问令牌

I was able to get the code from 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.

The instagram API says that "you simply have to POST this code, along with some app identification parameters, to our access_token endpoint."

 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? How do I put all these information as a variable and post it to the uri to get back the json object? Thank you

using ssh task runner

$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


Another approach -in case of you want to keep away of shell commands- is by using guzzle package or internal php cURL library