Change title and description

Hi, I have a php script and I’m trying to change title in the broadcast

I get the token with this:

$data = array(‘client_id’ => $client_id, ‘client_secret’ => $client_secret, ‘grant_type’ => ‘client_credentials’, ‘scope’ => ‘channel:manage:broadcast user:edit:broadcast’);

and this is the call:

curl_setopt($ch, CURLOPT_URL, ‘https://api.twitch.tv/helix/channels?broadcaster_id=’ . $user_id);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ‘PATCH’);

curl_setopt($ch, CURLOPT_POSTFIELDS, “{“title”:“NEWS”, “broadcaster_language”:“es”}”);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Client-ID: ’ . $client_id,
'Authorization: Bearer ’ . $token,
));

but i get:

“error”:“Bad Request”,“status”:400,“message”:“request must contain at least 1 channel property for updating”

What I need is to define the Title but also the “description”, please any advice will be good!
thanks
Federico

You are trying to use an App Access Token, which is not linked to a user. You must use the Implicit or Authorization Code Flow, not Client Credentials.

I could write a longer paragraph, but I already have here:

Additionally, @Dkamps18 pointed out elsewhere that your call is missing a Content-Type header. It should be set to application/json for how you are sending the data. (That will be why it can’t find your parameters and complains about not having any parameters passed to the endpoint.)

1 Like

Ok Thanks, following your tips, now I have an URL that generate the code (token) with 2 scope

https://id.twitch.tv/oauth2/authorize?client_id=[client_id]&response_type=code&scope=channel:manage:broadcast%20channel:manage:videos&redirect_uri=http://localhost

I pass the token (code) in the curl:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.twitch.tv/helix/channels?broadcaster_id=' . $user_id);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');

$jsonData = array(	'title' => 'NEWS', 'broadcaster_language' => 'es');

$jsonDataEncoded = json_encode($jsonData);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
	'Client-ID: ' . $client_id,
	'Authorization: Bearer ' . $token,
	'Content-Type: application/json'
	));

$result = curl_exec($ch);

but I have an “Unauthorized”,“status”:401,“message”:“Invalid OAuth token”

thanks for any help!
Federico

The code is not a token

See Step 3

In our example, your user gets redirected to:

http://localhost/?code=394a8bc98028f39660e53025de824134fb46313
    &scope=viewing_activity_read
    &state=c3ab8aa609ea11e793ae92361f002671
3) On your server, get an access token by making this request:

POST https://id.twitch.tv/oauth2/token
    ?client_id=<your client ID>
    &client_secret=<your client secret>
    &code=<authorization code received above>
    &grant_type=authorization_code
    &redirect_uri=<your registered redirect URI>

or for PHP example:

OK THANKS!!! PERFECT!
Seems is not possible to change the “live notification” via api…

Bye

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.