wip
This commit is contained in:
parent
2d83465596
commit
d52cec6f0a
|
@ -2,5 +2,35 @@
|
||||||
|
|
||||||
class FreshExtension_kagiSummarizer_Controller extends Minz_ActionController {
|
class FreshExtension_kagiSummarizer_Controller extends Minz_ActionController {
|
||||||
public function summarizeAction() {
|
public function summarizeAction() {
|
||||||
|
$this->view->_layout(false);
|
||||||
|
$entry_id = Minz_Request::param('id');
|
||||||
|
$entry_dao = FreshRSS_Factory::createEntryDao();
|
||||||
|
$entry = $entry_dao->searchById($entry_id);
|
||||||
|
|
||||||
|
if ($entry === null) {
|
||||||
|
echo json_encode(array('status' => 404));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$entry_link = urlencode($entry->link());
|
||||||
|
$url = 'https://kagi.com/mother/summary_labs?summary_type=summary&url=' . $entry_link;
|
||||||
|
|
||||||
|
$curl = curl_init();
|
||||||
|
curl_setopt($curl, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
||||||
|
'Content-Type: application/json; charset=UTF-8',
|
||||||
|
'Authorization: ' . FreshRSS_Context::$user_conf->kagi_token
|
||||||
|
));
|
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($curl, CURLOPT_HEADER, true);
|
||||||
|
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
$header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
|
||||||
|
$response_body = substr($response, $header_size);
|
||||||
|
|
||||||
|
return json_encode(array(
|
||||||
|
'response' => json_decode($response_body),
|
||||||
|
'status' => curl_getinfo($curl, CURLINFO_HTTP_CODE)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue