aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Poche.class.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2014-01-28 10:56:57 +0100
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2014-01-28 10:56:57 +0100
commit1b539ba1ece99774ef28eb149f7b6d21964260e9 (patch)
treef4d16115c79002f6b1f6eb73f2340faa0647cdaa /inc/poche/Poche.class.php
parent3e0e7e1208e8d3ee3b23df42ea119d7c50b0db5f (diff)
parentf878daeb8bc9245a294677e4ac141f8bd37c2b4f (diff)
downloadwallabag-1b539ba1ece99774ef28eb149f7b6d21964260e9.tar.gz
wallabag-1b539ba1ece99774ef28eb149f7b6d21964260e9.tar.zst
wallabag-1b539ba1ece99774ef28eb149f7b6d21964260e9.zip
Merge branch 'extraction-with-basic-auth' of git://github.com/aaa2000/poche into aaa2000-extraction-with-basic-auth
Diffstat (limited to 'inc/poche/Poche.class.php')
-rw-r--r--inc/poche/Poche.class.php21
1 files changed, 17 insertions, 4 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index d4733218..0be1668d 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -326,6 +326,22 @@ class Poche
326 ); 326 );
327 } 327 }
328 328
329 protected function getPageContent(Url $url)
330 {
331 $options = array('http' => array('user_agent' => 'poche'));
332 if (isset($_SERVER['AUTH_TYPE']) && "basic" === strtolower($_SERVER['AUTH_TYPE'])) {
333 $options['http']['header'] = sprintf(
334 "Authorization: Basic %s",
335 base64_encode(
336 sprintf('%s:%s', $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])
337 )
338 );
339 }
340 $context = stream_context_create($options);
341 $json = file_get_contents(Tools::getPocheUrl() . '/inc/3rdparty/makefulltextfeed.php?url='.urlencode($url->getUrl()).'&max=5&links=preserve&exc=&format=json&submit=Create+Feed', false, $context);
342 return json_decode($json, true);
343 }
344
329 /** 345 /**
330 * Call action (mark as fav, archive, delete, etc.) 346 * Call action (mark as fav, archive, delete, etc.)
331 */ 347 */
@@ -334,10 +350,7 @@ class Poche
334 switch ($action) 350 switch ($action)
335 { 351 {
336 case 'add': 352 case 'add':
337 $options = array('http' => array('user_agent' => 'poche')); 353 $content = $this->getPageContent($url);
338 $context = stream_context_create($options);
339 $json = file_get_contents(Tools::getPocheUrl() . '/inc/3rdparty/makefulltextfeed.php?url='.urlencode($url->getUrl()).'&max=5&links=preserve&exc=&format=json&submit=Create+Feed', false, $context);
340 $content = json_decode($json, true);
341 $title = $content['rss']['channel']['item']['title']; 354 $title = $content['rss']['channel']['item']['title'];
342 $body = $content['rss']['channel']['item']['description']; 355 $body = $content['rss']['channel']['item']['description'];
343 356