]> git.mxchange.org Git - friendica-addons.git/commitdiff
fbpost: Beautifying the import to friendica
authorMichael Vogel <icarus@dabo.de>
Thu, 3 Jan 2013 21:11:46 +0000 (22:11 +0100)
committerMichael Vogel <icarus@dabo.de>
Thu, 3 Jan 2013 21:11:46 +0000 (22:11 +0100)
statusnet+twitter: Beautifying the export to statusnet and twitter, solving the problem that posts were sometimes send twice

fbpost/fbpost.php
statusnet/statusnet.php
twitter/twitter.php

index 0c7e454a1664d0bad828f9786cc2e30db53399d5..51bed7ebb2d617726b025533b58a9bd754cae2c4 100644 (file)
@@ -1048,7 +1048,7 @@ function fbpost_fetchwall($a, $uid) {
                elseif (isset($item->name))
                        $_REQUEST["body"] .= "\n\n[b]" . $item->name."[/b]";
 
-               if(isset($item->caption)) {
+               /*if(isset($item->caption)) {
                        if(!isset($item->name) and isset($item->link))
                                $_REQUEST["body"] .= "\n\n[bookmark=".$item->link."]".$item->caption."[/bookmark]";
                        //else
@@ -1060,22 +1060,26 @@ function fbpost_fetchwall($a, $uid) {
                                        $_REQUEST["body"] .= "\n[url]".$item->link."[/url]\n";
                                else
                                        $_REQUEST["body"] .= "\n";
-               }
+               }*/
 
                $quote = "";
-               if(isset($item->description))
+               if(isset($item->description) and ($item->type != "photo"))
                        $quote = $item->description;
 
-               if (isset($item->properties))
-                       foreach ($item->properties as $property)
-                               $quote .= "\n".$property->name.": [url=".$property->href."]".$property->text."[/url]";
+               if(isset($item->caption) and ($item->type == "photo"))
+                       $quote = $item->caption;
+
+               //if (isset($item->properties))
+               //      foreach ($item->properties as $property)
+               //              $quote .= "\n".$property->name.": [url=".$property->href."]".$property->text."[/url]";
 
                if ($quote)
                        $_REQUEST["body"] .= "\n[quote]".$quote."[/quote]";
 
                // Only import the picture when the message is no video
                // oembed display a picture of the video as well
-               if ($item->type != "video") {
+               //if ($item->type != "video") {
+               if (($item->type != "video") and ($item->type != "photo")) {
                        if(isset($item->picture) && isset($item->link))
                                $_REQUEST["body"] .= "\n".'[url='.$item->link.'][img]'.fpost_cleanpicture($item->picture).'[/img][/url]';
                        else {
index d5097c13c2fa6b201869cf913edf2b812af64772..b5d55ed7c0bfaa9c4be4129d63bc783ff63626bc 100755 (executable)
@@ -448,6 +448,10 @@ function statusnet_shortenmsg($b, $max_char) {
        if ($b["title"] != "")
                $body = $b["title"]."\n\n".$body;
 
+       // Add some newlines so that the message could be cut better
+       $body = str_replace(array("[quote", "[bookmark", "[/bookmark]", "[/quote]"),
+                               array("\n[quote", "\n[bookmark", "[/bookmark]\n", "[/quote]\n"), $body);
+
        // remove the recycle signs and the names since they aren't helpful on twitter
        // recycle 1
        $recycle = html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8');
@@ -773,6 +777,11 @@ function statusnet_fetchtimeline($a, $uid) {
        $osecret = get_pconfig($uid, 'statusnet', 'oauthsecret');
        $lastid  = get_pconfig($uid, 'statusnet', 'lastid');
 
+       $application_name  = get_config('statusnet', 'application_name');
+
+       if ($application_name == "")
+               $application_name = $a->get_hostname();
+
        $connection = new StatusNetOAuth($api, $ckey,$csecret,$otoken,$osecret);
 
        $parameters = array("exclude_replies" => true, "trim_user" => true, "contributor_details" => false, "include_rts" => false);
@@ -793,7 +802,7 @@ function statusnet_fetchtimeline($a, $uid) {
                if ($post->in_reply_to_status_id != "")
                        continue;
 
-               if (!strpos($post->source, $a->get_hostname())) {
+               if (!strpos($post->source, $application_name)) {
                        $_SESSION["authenticated"] = true;
                        $_SESSION["uid"] = $uid;
 
index 3056f57b220529d2aef6b1d00023b787755fa339..2be686b30fed2b7956d83c21a5b51e470a824ce1 100755 (executable)
@@ -306,6 +306,10 @@ function twitter_shortenmsg($b) {
        if ($b["title"] != "")
                $body = $b["title"]."\n\n".$body;
 
+       // Add some newlines so that the message could be cut better
+       $body = str_replace(array("[quote", "[bookmark", "[/bookmark]", "[/quote]"),
+                       array("\n[quote", "\n[bookmark", "[/bookmark]\n", "[/quote]\n"), $body);
+
        // remove the recycle signs and the names since they aren't helpful on twitter
        // recycle 1
        $recycle = html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8');
@@ -581,6 +585,11 @@ function twitter_fetchtimeline($a, $uid) {
        $osecret = get_pconfig($uid, 'twitter', 'oauthsecret');
        $lastid  = get_pconfig($uid, 'twitter', 'lastid');
 
+       $application_name  = get_config('twitter', 'application_name');
+
+       if ($application_name == "")
+               $application_name = $a->get_hostname();
+
        require_once('library/twitteroauth.php');
        $connection = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
 
@@ -596,7 +605,7 @@ function twitter_fetchtimeline($a, $uid) {
                if ($post->id_str > $lastid)
                        $lastid = $post->id_str;
 
-               if (!strpos($post->source, $a->get_hostname())) {
+               if (!strpos($post->source, $application_name)) {
                        $_SESSION["authenticated"] = true;
                        $_SESSION["uid"] = $uid;