Skip to content

Commit

Permalink
fixed #10
Browse files Browse the repository at this point in the history
  • Loading branch information
zqzten committed Jun 18, 2018
1 parent b91cf02 commit 2ef2cac
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/zhihu.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,30 @@
initDownloadDir(true);

$response = request('https://www.zhihu.com/autocomplete?token='.urlencode($query));
$json = json_decode(html_entity_decode($response, ENT_QUOTES | ENT_HTML5))[0];
$json = json_decode($response)[0];

foreach ($json as $sugg) {
if (is_array($sugg)) {
$matched = true;
$type = $sugg[0];
$title = html_entity_decode($sugg[1], ENT_QUOTES | ENT_HTML5);
switch ($type) {
case 'topic':
$title = $sugg[1];
$subtitle = '【话题】'.$sugg[6].' 个精选回答';
$arg = 'https://www.zhihu.com/'.$type.'/'.$sugg[2];
$icon = saveAndReturnFile(str_replace('_s', '_m', $sugg[3]));
break;
case 'people':
$title = $sugg[1];
$subtitle = '【用户】'.$sugg[5];
$subtitle = '【用户】'.html_entity_decode($sugg[5], ENT_QUOTES | ENT_HTML5);
$arg = 'https://www.zhihu.com/'.$type.'/'.$sugg[2];
$icon = saveAndReturnFile(str_replace('_s', '_m', $sugg[3]));
break;
case 'question':
$title = $sugg[1];
$subtitle = '【问题】'.$sugg[4].' 个回答';
$arg = 'https://www.zhihu.com/'.$type.'/'.$sugg[3];
$icon = ICON;
break;
case 'article':
$title = $sugg[1];
$subtitle = '【文章】'.$sugg[4].' 个赞';
$arg = 'https://zhuanlan.zhihu.com/p/'.$sugg[3];
$icon = ICON;
Expand Down

0 comments on commit 2ef2cac

Please sign in to comment.