
04.11.2021, 21:31
|
|
Постоянный
Регистрация: 01.03.2016
Сообщений: 828
С нами:
5368054
Репутация:
448
|
|
Сообщение от òbi
@Mex-Vision, скорее всего передается не верный заголовок (не та версия апи или еще что)
Код:
Код:
Accept: application/vnd.twitchtv.v5+json
вот метод получения данных по айди канала для ранее представленного класса
PHP:
Код:
class
TwitchApiV5
{
.
.
.
/**
* @link https://dev.twitch.tv/docs/v5/reference/streams/#get-stream-by-user
*/
public
function
getStream
(
$channel
=
''
,
array
$arr
=
null
)
{
$parameters
=
$this
-
>
_parseArray
(
$arr
)
;
$url
=
self
:
:
KRAKEN_URL
.
'/streams/'
.
$channel
.
$parameters
;
curl_setopt_array
(
$this
-
>
curl
,
[
CURLOPT_URL
=
>
$url
,
CURLOPT_RETURNTRANSFER
=
>
1
,
CURLOPT_TIMEOUT
=
>
1
,
CURLOPT_HTTPHEADER
=
>
[
'Accept: application/vnd.twitchtv.v5+json'
,
'Client-ID: '
.
self
:
:
CLIENT_ID
]
]
)
;
return
json_decode
(
curl_exec
(
$this
-
>
curl
)
,
true
)
;
}
.
.
.
}
$api
=
new
TwitchApiV5
(
)
;
echo
''
;
print_r
(
$api
-
>
getStream
(
'729604925'
)
)
;
echo
''
;
результат
Код:
Код:
Array
(
[stream] => Array
(
[_id] => 43710028412
[game] => Lineage 2
[broadcast_platform] => live
[community_id] =>
[community_ids] => Array
(
)
[viewers] => 201
[video_height] => 1080
[average_fps] => 60
[delay] => 0
[created_at] => 2021-11-04T11:06:21Z
[is_playlist] =>
[stream_type] => live
[preview] => Array
(
[small] => https://static-cdn.jtvnw.net/previews-ttv/live_user_multiworld_essencel2-80x45.jpg
[medium] => https://static-cdn.jtvnw.net/previews-ttv/live_user_multiworld_essencel2-320x180.jpg
[large] => https://static-cdn.jtvnw.net/previews-ttv/live_user_multiworld_essencel2-640x360.jpg
[template] => https://static-cdn.jtvnw.net/previews-ttv/live_user_multiworld_essencel2-{width}x{height}.jpg
)
[channel] => Array
(
[mature] =>
[status] => Play with me on top essence server | DISCORD (info)
[broadcaster_language] => en
[broadcaster_software] =>
[display_name] => multiworld_essencel2
[game] => Lineage 2
[language] => ru
[_id] => 729604925
[name] => multiworld_essencel2
[created_at] => 2021-09-26T09:37:34.918005Z
[updated_at] => 2021-11-04T16:57:05.13631Z
[partner] =>
[logo] => https://static-cdn.jtvnw.net/jtv_user_pictures/61ca7622-5420-48a7-b9bf-61e0ce9297e7-profile_image-300x300.png
[video_banner] =>
[profile_banner] =>
[profile_banner_background_color] =>
[url] => https://www.twitch.tv/multiworld_essencel2
[views] => 629
[followers] => 3
[broadcaster_type] =>
[description] =>
[private_video] =>
[privacy_options_enabled] =>
)
)
)
представленные результаты с только что сделанных запросов этим скриптом, так что кракен работает
К сожалению нет(
The v5 API is deprecated and will be shutdown on February 28, 2022. Applications that have not accessed v5 before July 15, 2021 no longer have access to v5. For more information on the v5 API shutdown plan, see Redirecting... and the Twitch API documentation at Twitch API.
|
|
|