]> git.mxchange.org Git - friendica-addons.git/blobdiff - dwpost/dwpost.php
Rename "fetchUrl" and "fetchUrlFull" to "fetch" and "fetchFull"
[friendica-addons.git] / dwpost / dwpost.php
index 45673714345b445ffc4a17c9e3f069b6dcbcbee5..9a973b672f2859d633bfca96d42ceb706fc973d8 100644 (file)
 use Friendica\App;
 use Friendica\Content\Text\BBCode;
 use Friendica\Core\Hook;
-use Friendica\Core\L10n;
 use Friendica\Core\Logger;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Model\Tag;
 use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Network;
 use Friendica\Util\XML;
 
 function dwpost_install()
@@ -192,7 +191,7 @@ function dwpost_send(App $a, array &$b)
                $title = $b['title'];
                $post = BBCode::convert($b['body']);
                $post = XML::escape($post);
-               $tags = dwpost_get_tags($b['tag']);
+               $tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]);
 
                $date = DateTimeFormat::convert($b['created'], $tz);
                $year = intval(substr($date,0,4));
@@ -231,18 +230,9 @@ EOT;
                Logger::log('dwpost: data: ' . $xml, Logger::DATA);
 
                if ($dw_blog !== 'test') {
-                       $x = Network::post($dw_blog, $xml, ["Content-Type: text/xml"])->getBody();
+                       $x = DI::httpRequest()->post($dw_blog, $xml, ["Content-Type: text/xml"])->getBody();
                }
 
                Logger::log('posted to dreamwidth: ' . ($x) ? $x : '', Logger::DEBUG);
        }
 }
-
-function dwpost_get_tags($post)
-{
-       preg_match_all("/\]([^\[#]+)\[/", $post, $matches);
-
-       $tags = implode(', ', $matches[1]);
-
-       return $tags;
-}