From 150a8152a4be0d5cdb45cbbcd3f1490578865d96 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Wed, 28 Aug 2019 23:48:53 +0900 Subject: [PATCH] =?UTF-8?q?=E6=8C=87=E6=91=98=E7=AE=87=E6=89=80=E3=81=AE?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/NijieResolver.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/MetadataResolver/NijieResolver.php b/app/MetadataResolver/NijieResolver.php index f511092..33408ab 100644 --- a/app/MetadataResolver/NijieResolver.php +++ b/app/MetadataResolver/NijieResolver.php @@ -33,8 +33,8 @@ class NijieResolver implements Resolver $res = $this->client->get($url); if ($res->getStatusCode() === 200) { - $metadata = $this->ogpResolver->parse((string) $res->getBody()); $html = (string) $res->getBody(); + $metadata = $this->ogpResolver->parse($html); $crawler = new Crawler($html); // DomCrawler内でjson内の日本語がHTMLエンティティに変換されるのでhtml_entity_decode @@ -43,8 +43,6 @@ class NijieResolver implements Resolver // 改行がそのまま入っていることがあるのでデコード前にエスケープが必要 $data = json_decode(preg_replace('/\r?\n/', '\n', $json), true); - $tags = $crawler->filter('#view-tag span.tag_name')->extract('_text'); - $metadata->title = $data['name']; $metadata->description = '投稿者: ' . $data['author']['name'] . PHP_EOL . $data['description']; if ( @@ -55,7 +53,7 @@ class NijieResolver implements Resolver // サムネイルからメイン画像に $metadata->image = str_replace('__rs_l160x160/', '', $data['thumbnailUrl']); } - $metadata->tags = $tags; + $metadata->tags = $crawler->filter('#view-tag span.tag_name')->extract('_text'); return $metadata; } else {