How do i get a client id for my application in localhost?

I try to get a client id for my application but when I press the submit button I get this error:

You must have two factor enabled to manage applications

what am I doing wrong?

if I got this straight when I’m a developer and create an application that gets the channel name and returns if it streams live, I need two things: the channel username from my client and a client id for my application that I make on my dashboard. have I understand correctly?
Btw this is my code:
<?php
date_default_timezone_set(‘UTC’);
$client_id = ‘ls2awgx5gfg9m1q6iopdqb1b7d0y6a’;
$user = ‘slotakias’;
function user_stream($client_id, $user)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://api.twitch.tv/helix/streams?user_login=$user”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
“Client-ID: $client_id”
));
$profile_data = json_decode(curl_exec($ch), true);
curl_close($ch);
return $profile_data;
}
function is_live($data)
{
if (!isset($data[‘data’][0])) {
return false;
} else {
return true;
}
}
$profile_data = user_stream($client_id, $user);
if (is_live($profile_data)) {
$title = $profile_data[‘data’][0][‘title’];
$viewer_count = $profile_data[‘data’][0][‘viewer_count’];
$game_id = $profile_data[‘data’][0][‘game_id’];
$went_live_at = DateTime::createFromFormat(“Y-m-d H:i:s”, date(“Y-m-d H:i:s”, strtotime($profile_data[‘data’][0][‘started_at’])))->format(‘Y-m-d H:i:s’);
$started = date_create($went_live_at);
$now = date_create(date(‘Y-m-d H:i:s’));
$diff = date_diff($started, $now);
$hours = $diff->h;
$minutes = $diff->i;
$game_data = game_data($client_id, $game_id);
$game_name = $game_data[‘data’][0][‘name’];
$game_artwork = $game_data[‘data’][0][‘box_art_url’];
echo “$user is playing $game_name, started streaming $hours hours $minutes minutes ago and has $viewer_count viewers TITLE: $title”;
} else {
echo “$user is not live”;
}

I think it is ok but when I run it for a test in http://sandbox.onlinephpfunctions.com/
I get this error:


Fatal error: Uncaught Error: Call to undefined function curl_init() in [...][...]:7 Stack trace: #0 [...][...](25): user_stream('ls2awgx5gfg9m1q...', 'slotakias') #1 {main} thrown in [...][...] on line 7

Correct.

I use my client ID to look up the stream status of who ever I want.

curl or the curl extension is not installed/available to your PHP installation

1 Like

ok now i put this in the browser:
https://api.twitch.tv/helix/streams?user_login=slotakias?client_id=15p1iip9hzv76l431xw0xex8rnsta0
and i get an error.
{“error”:“Unauthorized”,“status”:401,“message”:“Must provide a valid Client-ID or OAuth token”}
my client id is valid btw.

  1. URL’s need to be ?this=thing&that=another not ?this=thing?that=another
  2. The API requires the client ID as a header, not as a query string argument

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