Advertisement
MyOhMyke

Untitled

Feb 19th, 2023
813
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1.  
  2.  
  3. <?php
  4.  
  5. //These are from your tiltify app info
  6. $clientID = "AppID";
  7. $clientSEC = "AppSecret";
  8. $oldToken = "AppV3Token";
  9.  
  10.  
  11. $userCode = "Token generated by /oauth/authorize";
  12.  
  13. //use the userCode in a curl php request to get these
  14. $accessToken = "access token generated using userCode";
  15. $refreshToken = "refresh token generated using userCode";
  16.  
  17.  
  18. //refresh your token.
  19.  
  20.  
  21. //The url you wish to send the POST request to
  22. $url = 'https://v5api.tiltify.com/oauth/token/';
  23.  
  24. //The data you want to send via POST
  25. $fields = array(
  26.  
  27. 'client_id' => $clientID,
  28. 'client_secret' => $clientSEC,
  29. 'redirect_uri' => 'https://localhost',
  30. 'grant_type' => 'refresh_token',
  31. );
  32.  
  33. //url-ify the data for the POST
  34. $fields_string = http_build_query($fields);
  35.  
  36. //open connection
  37. $ch = curl_init();
  38.  
  39. //set the url, number of POST vars, POST data
  40. curl_setopt($ch,CURLOPT_URL, $url);
  41. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer ' . $refreshToken ));
  42. curl_setopt($ch,CURLOPT_POST, true);
  43. curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
  44.  
  45. //So that curl_exec returns the contents of the cURL; rather than echoing it
  46. curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
  47.  
  48. //execute post
  49. $result = curl_exec($ch);
  50. echo $result;
  51.  
  52.  
  53. ?>
  54.  
  55.  
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement