ようつべである20以上件のコメも見える
このコミットが含まれているのは:
コミット
8f2560a70e
|
@ -36,6 +36,11 @@ class Prayer {
|
|||
$comments = DB::table('blg_comments')->where('video_id', $vid)->orderBy('id', 'asc')->get()->toArray();
|
||||
$ytslug = explode('?v=', $res->youtube);
|
||||
$res->ytcomment = (isset($ytslug[1]) ? $this->getYouTubeCome($ytslug[1]) : array());
|
||||
if ($res->ytcomment['nextPage'] != '') {
|
||||
while ($res->ytcomment['nextPage'] != '') {
|
||||
$res->ytcomment = $this->checkYouTubeCome($res->ytcomment, $ytslug[1], $res->ytcomment['nextPage']);
|
||||
}
|
||||
}
|
||||
$res->nicocomment = array();
|
||||
$res->bccomment = array();
|
||||
$res->lbcomment = array();
|
||||
|
@ -61,14 +66,24 @@ class Prayer {
|
|||
}
|
||||
|
||||
$res->user = userDetail(null, $this->cook);
|
||||
$res->comments = $comments;
|
||||
$res->comments['total'] = count($comments);
|
||||
$res->comments['come'] = $comments;
|
||||
|
||||
return view('pages.site.video.prayer', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
|
||||
}
|
||||
|
||||
function getYouTubeCome ($slug) {
|
||||
function checkYouTubeCome ($res, $slug, $next='') {
|
||||
$come = $this->getYouTubeCome($slug, $next);
|
||||
foreach ($come['come'] as $com) { $res['come'][] = $com; }
|
||||
$res['total'] += $come['total'];
|
||||
$res['nextPage'] = $come['nextPage'];
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getYouTubeCome ($slug, $page='') {
|
||||
$ch = curl_init();
|
||||
$url = 'https://www.googleapis.com/youtube/v3/commentThreads?part=snippet%2Creplies&moderationStatus=published&videoId='.$slug.'&key='.env('YOUTUBE_API');
|
||||
$url = 'https://www.googleapis.com/youtube/v3/commentThreads?part=snippet%2Creplies&moderationStatus=published&videoId='.$slug.'&key='.env('YOUTUBE_API').'&pageToken='.$page;//.'&order=date&pageToken='.$page;
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
|
||||
|
@ -80,6 +95,7 @@ class Prayer {
|
|||
$come = array();
|
||||
$get = json_decode($get, false);
|
||||
if (isset($get->error)) return array();
|
||||
$come['come'] = array();
|
||||
|
||||
foreach ($get->items as $g) {
|
||||
$g->comment = new \stdClass();
|
||||
|
@ -103,9 +119,13 @@ class Prayer {
|
|||
}
|
||||
}
|
||||
|
||||
$come[] = $g->comment;
|
||||
$come['come'][] = $g->comment;
|
||||
}
|
||||
|
||||
$come['total'] = $get->pageInfo->totalResults;
|
||||
$come['prevPage'] = (isset($get->prevPageToken) ? $get->prevPageToken : '');
|
||||
$come['nextPage'] = (isset($get->nextPageToken) ? $get->nextPageToken : '');
|
||||
|
||||
return $come;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<template>
|
||||
<div id="comments" class="comments-area clearfix">
|
||||
<h3 class="comments-count section-heading uppercase"><span>{{ total }} コメント</span></h3>
|
||||
<h3 class="comments-count section-heading uppercase"><span>{{ comment.total }}{{ (comment.nextPage ? '以上' : '') }} 件のコメント</span></h3>
|
||||
<div v-if="total === 0">コメントがありません。</div>
|
||||
<span v-else>
|
||||
<ul class="commentlist" v-for="(c, i) in comment" :key="`comment-${i}`">
|
||||
<ul class="commentlist" v-for="(c, i) in comment.come" :key="`comment-${i}`">
|
||||
<li class="comment even thread-even depth-1" :id="`li-comment-${c.id}`">
|
||||
<div class="commentnumber">{{ i+1 }}</div>
|
||||
<div class="commentnumber">{{ Number(i)+1 }}</div>
|
||||
<div :id="`comment-${c.id}`">
|
||||
<div>
|
||||
<cite class="fn">
|
||||
<span v-if="isvideo === 'n'">
|
||||
<img style="height: 24px;" :src="c.icon" :alt="`${c.name}さんのアイコン`">
|
||||
<a :href="c.channel">{{ (c.name || '名無しのテクニシャン') }}</a>
|
||||
<a :href="c.channel" style="overflow-wrap: break-word;">{{ (c.name || '名無しのテクニシャン') }}</a>
|
||||
</span>
|
||||
<span v-else>
|
||||
<span v-if="c.user_id"><a :href="`/profile/${c.user_id}`" :style="c.showcol"><img style="width: 24px; height: 24px;" :src="c.avatar" :alt="`${c.showname}さんのアイコン`"> {{ c.showname }}</a></span>
|
||||
|
@ -91,7 +91,7 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
props: { user: Object, slug: '', isvideo: '', comments: Array },
|
||||
props: { user: Object, slug: '', isvideo: '', comments: Object },
|
||||
data: function () { return { comment: this.comments, newComment: {}, err: '', loading: true, sending: false } },
|
||||
computed: {
|
||||
total: function () {
|
||||
|
@ -106,7 +106,6 @@
|
|||
this.newComment.mail = '';
|
||||
this.newComment.text = '';
|
||||
},
|
||||
page () {},
|
||||
send () {
|
||||
if (this.isvideo !== 'n') {
|
||||
this.err = '';
|
||||
|
|
新しいイシューから参照