]> git.mxchange.org Git - friendica-addons.git/blobdiff - tumblr/tumblr.php
Tumblr: Bugfix
[friendica-addons.git] / tumblr / tumblr.php
index deba857e5ffe34241c6ea4fee887d493242f14f3..95755e3988f3a61bef405e2b85f1f3c95ab2d4b5 100755 (executable)
@@ -166,19 +166,33 @@ function tumblr_send(&$a,&$b) {
                        }
                }
                if(count($tag_arr))
-                       $tags = implode(',',$tag_arr);          
-
+                       $tags = implode(',',$tag_arr);
+
+               $link = "";
+               if ($b['title'] == '') {
+                       // Take the description from the bookmark
+                       if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches))
+                               $link = $matches[1];
+                               $b['title'] = html_entity_decode($matches[2],ENT_QUOTES,'UTF-8');
+               }
 
                $params = array(
                        'email' => $tmbl_username,
                        'password' => $tmbl_password,
-                       'title' => (($b['title']) ? $b['title'] : t('Post from Friendica')),
-                       'type' => 'regular',
                        'format' => 'html',
                        'generator' => 'Friendica',
-                       'tags' => $tags,
-                       'body' => bbcode($b['body'])
-               );
+                       'tags' => $tags);
+
+               if ($link != '') {
+                       $params['type'] = "link";
+                       $params['name'] = $b['title'];
+                       $params['url'] = $link;
+                       $params['description'] = bbcode($b['body']);
+               } else {
+                       $params['type'] = "regular";
+                       $params['title'] = $b['title'];
+                       $params['body'] = bbcode($b['body']);
+               }
 
                $x = post_url($tmbl_blog,$params);
                $ret_code = $a->get_curl_code();
@@ -187,7 +201,7 @@ function tumblr_send(&$a,&$b) {
                elseif($ret_code == 403)
                        logger('tumblr_send: authentication failure');
                else
-                       logger('tumblr_send: general error: ' . print_r($x,true)); 
+                       logger('tumblr_send: general error: ' . print_r($x,true));
 
        }
 }