]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/scripts/testfeed.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / OStatus / scripts / testfeed.php
old mode 100644 (file)
new mode 100755 (executable)
index 82a1c65..2a12069
@@ -33,9 +33,11 @@ Mainly intended for testing funky feed formats.
 
 END_OF_HELP;
 
-require_once INSTALLDIR.'/scripts/commandline.inc';
+require_once INSTALLDIR.'/scripts/commandline.inc.php';
 
-if (empty($args[0]) || !Validate::uri($args[0])) {
+$validate = new Validate();
+
+if (empty($args[0]) || !$validate->uri($args[0])) {
     print "$helptext";
     exit(1);
 }
@@ -45,15 +47,17 @@ $skip = have_option('skip') ? intval(get_option_value('skip')) : 0;
 $count = have_option('count') ? intval(get_option_value('count')) : 0;
 
 
-$sub = FeedSub::staticGet('topic', $feedurl);
+$sub = FeedSub::getKV('uri', $feedurl);
 if (!$sub) {
     print "Feed $feedurl is not subscribed.\n";
     exit(1);
 }
 
-$xml = file_get_contents($feedurl);
-if ($xml === false) {
-    print "Bad fetch.\n";
+// Fetch the URL
+try {
+    $xml = HTTPClient::quickGet($feedurl, 'text/html,application/xhtml+xml');
+} catch (Exception $e) {
+    echo sprintf("Could not fetch feedurl %s (%d).\n", $e->getMessage(), $e->getCode());
     exit(1);
 }
 
@@ -85,4 +89,5 @@ if ($skip || $count) {
     }
 }
 
+echo "Calling event StartFeedSubReceive\n";
 Event::handle('StartFeedSubReceive', array($sub, $feed));