zend framework3の中に表示する特定のビデオからのコメントを表示する必要があります。Zend Framework 3を通してYouTube APIからのコメントを取得して表示する
は私がlistCommentThreads要求だけでなく、listComments用のためのユーチューブのAPIから適切な応答を取得していと思います。私の問題は、zendに正しく表示させることができないということです。
サービスからの私の機能:
public function getCommentsList($id)
{
try {
$videoCommentThreads = $this -> youtube -> commentThreads -> listCommentThreads('snippet', array(
'videoId' => $id,
'textFormat' => 'plainText',
));
$parentId = $videoCommentThreads[0]['id'];
$comments = $this -> youtube -> comments -> listComments('snippet', array(
'parentId' => $parentId,
'textFormat' => 'plainText',
));
} catch (\Exception $e) {
die($e->getMessage());
}
return $comments;
}
コントローラからの私の機能:
public function commentsAction()
{
$id = $this->params()->fromRoute('id');
$comments = $this->ytService->getCommentsList($id);
$view = new ViewModel(['comments' => [$comments]]);
$view->setTerminal(true);
return $view;
}
私comments.phtmlファイル:
comments...<br />
<strong>
<?php
echo $comments['snippet']['topLevelComment']['snippet']['textDisplay'];
?>
</strong><br/>
私はいくつかの異なる方法で表示しました。何も私にとってはうまくいかないようです。それが今であるとして、私はこのようなエラーを取得しています:
お知らせ:未定義のインデックス:Cでのスニペット:\\モジュール\ YouTubeの\ビュー\ユーチューブの\指数\ comments.phtmlライン上の4私が試した
をcomments.phtmlのこのようなもの:
comments...<BR />
<?php
foreach ($comments as $f){
echo $f['snippet']['textOriginal'];
echo "<BR />";
}
?>
私は何も得ていないし、間違いもない。私はいくつかのビデオのためのvar_dump($コメント)をしようとしたとき、私はそのようなものだ:
comments...
array(1) { [0]=> object(Google_Service_YouTube_CommentListResponse)#235 (17) { ["collection_key":protected]=> string(5) "items" ["etag"]=> string(57) ""ld9biNPKjAjgjV7EZ4EKeEGrhao/8nuwXL_uo880WPx5G4SpQo1F1Hg"" ["eventId"]=> NULL ["itemsType":protected]=> string(30) "Google_Service_YouTube_Comment" ["itemsDataType":protected]=> string(5) "array" ["kind"]=> string(27) "youtube#commentListResponse" ["nextPageToken"]=> string(112) "Q2h3Z29xZlEwS09GMkFJeUVRZ0tFQUFZeWNlUWtaclExd0lnQVNnQkVoNElCUklhVldkNFIySklYMWx5YmxSU2IycHFPV1I2ZURSQllVRkNRV2M=" ["pageInfoType":protected]=> string(31) "Google_Service_YouTube_PageInfo" ["pageInfoDataType":protected]=> string(0) "" ["tokenPaginationType":protected]=> string(38) "Google_Service_YouTube_TokenPagination" ["tokenPaginationDataType":protected]=> string(0) "" ["visitorId"]=> NULL ["internal_gapi_mappings":protected]=> array(0) { } ["modelData":protected]=> array(0) { } ["processed":protected]=> array(0) { } ["pageInfo"]=> object(Google_Service_YouTube_PageInfo)#328 (5) { ["resultsPerPage"]=> int(20) ["totalResults"]=> NULL ["internal_gapi_mappings":protected]=> array(0) { } ["modelData":protected]=> array(0) { } ["processed":protected]=> array(0) { } } ["items"]=> array(17) { [0]=> object(Google_Service_YouTube_Comment)#245 (9) { ["etag"]=> string(57) ""ld9biNPKjAjgjV7EZ4EKeEGrhao/yMpehVGKelxJUnku4t5qoe2sMUY"" ["id"]=> string(68) "z23sdhx5esvoulnlbacdp432ahlzxlfnoual3lzfrblw03c010c.1511294181102888" ["kind"]=> string(15) "youtube#comment" ["snippetType":protected]=> string(37) "Google_Service_YouTube_CommentSnippet" ["snippetDataType":protected]=> string(0) "" ["internal_gapi_mappings":protected]=> array(0) { } ["modelData":protected]=> array(0) { } ["processed":protected]=> array(0) { } ["snippet"]=> object(Google_Service_YouTube_CommentSnippet)#330 (18) { ["authorChannelId"]=> array(1) { ["value"]=> string(24) "UCAKvIEx6MoenkvZau8zcTaw" } ["authorChannelUrl"]=> string(55) "http://www.youtube.com/channel/UCAKvIEx6MoenkvZau8zcTaw" ["authorDisplayName"]=> string(7) "Adog312" ["authorProfileImageUrl"]=> string(107) "https://yt3.ggpht.com/-Vl_H7Y8JbEo/AAAAAAAAAAI/AAAAAAAAAAA/luI5nRagMa4/s28-c-k-no-mo-rj-c0xffffff/photo.jpg" ["canRate"]=> bool(true) ["channelId"]=> NULL ["likeCount"]=> int(0) ["moderationStatus"]=> NULL ["parentId"]=> string(51)"z23sdhx5esvoulnlbacdp432ahlzxlfnoual3lzfrblw03c010c" ["publishedAt"]=> string(24) "2017-11-21T19:56:21.000Z" ["textDisplay"]=> string(127) "oh, i thought that with the "add the salt" thing, it was just a joke i missed, like maybe you messed up adding the salt somehow" ["textOriginal"]=> string(127) "oh, i thought that with the "add the salt" thing, it was just a joke i missed, like maybe you messed up adding the salt somehow" ["updatedAt"]=> string(24) "2017-11-21T19:56:21.000Z" ["videoId"]=> NULL ["viewerRating"]=> string(4) "none" ["internal_gapi_mappings":protected]=> array(0) { } ["modelData":protected]=> array(0) { } ["processed":protected]=> array(0) { } } }
...それが行くのと
を行くが、私は私が得た
var_dump($comments['snippet']['textDisplay']);
を行うことをしようとしたときNULLのみ
何が間違っていますか?