]> git.mxchange.org Git - friendica.git/blobdiff - include/Scrape.php
OStatus: The gcontact table will now be updated from the conversation as well
[friendica.git] / include / Scrape.php
index cb192c77c2cd5c8c21580a51efe36920b8474076..bc6aebbdcfdee7b388c57f6905e2f008dc258647 100644 (file)
@@ -12,6 +12,18 @@ function scrape_dfrn($url, $dont_probe = false) {
 
        logger('scrape_dfrn: url=' . $url);
 
+       // Try to fetch the data from noscrape. This is faster than parsing the HTML
+       $noscrape = str_replace("/hcard/", "/noscrape/", $url);
+       $noscrapejson = fetch_url($noscrape);
+       $noscrapedata = array();
+       if ($noscrapejson) {
+               $noscrapedata = json_decode($noscrapejson, true);
+
+               if (is_array($noscrapedata))
+                       if ($noscrapedata["nick"] != "")
+                               return($noscrapedata);
+       }
+
        $s = fetch_url($url);
 
        if(! $s)
@@ -91,8 +103,7 @@ function scrape_dfrn($url, $dont_probe = false) {
                        }
                }
        }
-
-       return $ret;
+       return array_merge($ret, $noscrapedata);
 }}
 
 
@@ -235,7 +246,9 @@ function scrape_feed($url) {
        $a = get_app();
 
        $ret = array();
-       $s = fetch_url($url);
+       $cookiejar = tempnam(get_temppath(), 'cookiejar-scrape-feed-');
+       $s = fetch_url($url, false, $redirects, 0, Null, $cookiejar);
+       unlink($cookiejar);
 
        $headers = $a->get_curl_headers();
        $code = $a->get_curl_code();
@@ -559,10 +572,11 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
                                $pubkey = $hcard_key;
                }
        }
-
        if($diaspora && $diaspora_base && $diaspora_guid) {
-               if($mode == PROBE_DIASPORA || ! $notify) {
-                       $notify = $diaspora_base . 'receive/users/' . $diaspora_guid;
+               $diaspora_notify = $diaspora_base.'receive/users/'.$diaspora_guid;
+
+               if($mode == PROBE_DIASPORA || ! $notify || ($notify == $diaspora_notify)) {
+                       $notify = $diaspora_notify;
                        $batch  = $diaspora_base . 'receive/public' ;
                }
                if(strpos($url,'@'))
@@ -661,7 +675,9 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
                                $vcard['photo'] = $feedret['photo'];
                        require_once('library/simplepie/simplepie.inc');
                        $feed = new SimplePie();
-                       $xml = fetch_url($poll);
+                       $cookiejar = tempnam(get_temppath(), 'cookiejar-scrape-feed-');
+                       $xml = fetch_url($poll, false, $redirects, 0, Null, $cookiejar);
+                       unlink($cookiejar);
 
                        logger('probe_url: fetch feed: ' . $poll . ' returns: ' . $xml, LOGGER_DATA);
                        $a = get_app();