Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //These are from your tiltify app info
- $clientID = "AppID";
- $clientSEC = "AppSecret";
- $oldToken = "AppV3Token";
- $userCode = "Token generated by /oauth/authorize";
- //use the userCode in a curl php request to get these
- $accessToken = "access token generated using userCode";
- $refreshToken = "refresh token generated using userCode";
- //refresh your token.
- //The url you wish to send the POST request to
- $url = 'https://v5api.tiltify.com/oauth/token/';
- //The data you want to send via POST
- $fields = array(
- 'client_id' => $clientID,
- 'client_secret' => $clientSEC,
- 'redirect_uri' => 'https://localhost',
- 'grant_type' => 'refresh_token',
- );
- //url-ify the data for the POST
- $fields_string = http_build_query($fields);
- //open connection
- $ch = curl_init();
- //set the url, number of POST vars, POST data
- curl_setopt($ch,CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer ' . $refreshToken ));
- curl_setopt($ch,CURLOPT_POST, true);
- curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
- //So that curl_exec returns the contents of the cURL; rather than echoing it
- curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
- //execute post
- $result = curl_exec($ch);
- echo $result;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement