No, modify your existing script as needed. The GitHub is an example that demonstrates how to get a token.
As an example this can example be run as a command line script.
If you don’t have a command line/ssh on your hosting then you don’t have a command line to use. So your current script is running as a web page I guess, so you can put the code there inside your webpage
Got it, I have uploaded the config.php and generate_and_maintain_token.php, and I edited the config with the app client id and secret, but when trying to access my localhost http://localhost/twitch/generate_and_maintain_token.php to generate token it give me that error:
Failed with 0 doesn’t offer any information as to what the issue is.
In most cases, as this is locahost, this suggests a problem with SSL/TLS negotiation most likely that your local SSL/TLS cert bundle is invalid/out of date and needs to be updated
Refer to the instructions for this for whatever is running/providing your localhost
You’re right, I tried to upload it to live server cPanel and it works fine… thanks so much, do i need to generate this token every time when it expire expires_in, how to make it automatically with cron job maybe?
In this example it sores the generated token in auth.json
And whenever generate_and_maintain_token.php is run (likely via cron) it will load the token, validate it and regenerate if theres less than an hour left on it.
So, if you retrain the token into “storage” then you can use the token till it’s close to expire.
But depends how you use the otken and what makes sense for your application and usage