我正在使用Youtube Data API并尝试收到聊天消息,因为我必须提供df3 <- df3 %>% left_join(df2)
和lifeChatId
参数
我的代码
part
我收到错误
$guzzle_client = new Client();
$res = $guzzle_client->request('GET', 'https://www.googleapis.com/youtube/v3/liveChat/messages',
[
'liveChatId' => $broadcastsResponse['modelData']['snippet']['liveChatId'],
'part' => 'id,snippet'
]
);
但我确定我提供了两个必需的参数。 这个var_dump写在guzzle请求之前
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter: liveChatId",
"locationType": "parameter",
"location": "liveChatId"
},
{
"domain": "global",
"reason": "required",
"message": "Required parameter: part",
"locationType": "parameter",
"location": "part"
}
],
"code": 400,
"message": "Required parameter: liveChatId"
}
}
返回
var_dump([
'liveChatId' => $broadcastsResponse['modelData']['snippet']['liveChatId'],
'part' => 'id,snippet'
]);)
知道我为什么会收到这样的错误吗?
答案 0 :(得分:1)
尝试使用query
请求选项将它们作为查询字符串参数传递。
$guzzle_client = new Client();
$liveChatId = $broadcastsResponse['modelData']['snippet']['liveChatId'];
$res = $guzzle_client->request('GET', 'https://www.googleapis.com/youtube/v3/liveChat/messages', [
'query' => ['liveChatId' => $liveChatId, 'part' => 'id,snippet']
]);