Get clips by user id

anyone can provide the code for
Get clips by user id in php

As documented

It’s just a basic curl request. For example

<?php

    $ch = curl_init('https://api.twitch.tv/helix/clips?id=FOO');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Client-ID: yourclientID',
        'Authorization: Bearer YourOauthToken'
    ));
    $r = curl_exec($ch);
    $i = curl_getinfo($ch);
    curl_close($ch);

    if ($i['http_code'] == 200) {
        $data = json_decode($r);
        if (json_last_error() == JSON_ERROR_NONE) {
            // do stuff with $data
        } else {
            echo 'Faiked with ' . $r;
        }
    } else {
        echo 'Failed with ' . $r;
    }

This doesn’t cover how to get an oAuth token to use, also not tested, jsut off the top of my head

An uncaught Exception was encountered

Type: ParseError

Message: syntax error, unexpected ‘curl_setopt’ (T_STRING)

Line Number: 1097

Line: 282
Function: require_once

I missed a ; on the first line.

Basic PHP should should be able to fix this yourself

$ch = curl_init('https://api.twitch.tv/helix/clips?id=FOO');

no response
everything is passed in api.
another solution
please provide.

What error do you get?

Did you generate an oAuth token to use?

yes i have process for login then get token and userid
but no response data

You must of got an error of “failed with” message

for example
userid 248145136
this is get clips

$ch = curl_init('https://api.twitch.tv/helix/clips?id=FOO')

Should be

$ch = curl_init('https://api.twitch.tv/helix/clips?broadcaster_id=248145136')

As per the docs I linked

i have no get data
can u help
any other working code to get clip by user id

This code returns nothing or a “failed with” message. if you are getting nothing you didn’t update the code to do something with $data

You need to add code to // do stuff with data

And if something is not working, you need to post you code and describe whats not working

Means nothing

You need to add code to // do stuff with data

print_r($data);

to set

image

Works fine here

can u provide
temp.php file code

<?php

    $ch = curl_init('https://api.twitch.tv/helix/clips?broadcaster_id=248145136');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Client-ID: yourclientID',
        'Authorization: Bearer YourOauthToken'
    ));
    $r = curl_exec($ch);
    $i = curl_getinfo($ch);
    curl_close($ch);

    if ($i['http_code'] == 200) {
        $data = json_decode($r);
        if (json_last_error() == JSON_ERROR_NONE) {
            // do stuff with $data
            print_r($data);
        } else {
            echo 'Faiked with ' . $r;
        }
    } else {
        echo 'Failed with ' . $r;
    }

It is the same as the code I already posted just with my ClientID and Token instead of a placeholder

Failed with {“error”:“Unauthorized”,“status”:401,“message”:“Invalid OAuth token”}

Then your oAuth token is invalid.

Authentication is covered here

My code for getting clips does not cover how to get a token

hi
can u provide client id and auth token

Auth Tokens can not be shared with other users, they are private and should be treated like passwords.

Barry linked the authentication docs, you should follow the step by step instructions to obtain your own auth token to use with API requests.