From 03678716fe657cb9498073f7fc7f74b5883f7faf Mon Sep 17 00:00:00 2001 From: tonnerkiller Date: Sat, 16 Aug 2014 13:13:57 +0200 Subject: api_posting.bb is a new doco file that explains posting to the redmatrix from an external program by exampple of command line tool curl main.bb is an updated version of the doco main site with a link to api_posting.bb --- doc/api_posting.bb | 23 +++++++++++++++++++++++ doc/main.bb | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 doc/api_posting.bb diff --git a/doc/api_posting.bb b/doc/api_posting.bb new file mode 100644 index 000000000..eeb7127fd --- /dev/null +++ b/doc/api_posting.bb @@ -0,0 +1,23 @@ +[b][size=xx-large]Posting to the Matrix via the API[/size][/b] + +The API allows you to post to the red# by HTTP POST request. Below you see an example using the command line tool cURL: + +[code]curl -ssl -u [color=blue]$E-Mail[/color]:[color=blue]$Password[/color] -d "[color=blue]$Parameters[/color]" [url][observer.baseurl]/api/statuses/update +[/url][/code] +[table][tr][td]$E-Mail:[/td][td]The E-Mail Adress you use to login[/td][/tr] +[tr][td]$Password:[/td][td]The Password you use to login[/td][/tr] +[tr][td]$Parameters:[/td][td]That's the interesting part, here you insert the content you want to send using the following parameters:[/td][/tr][/table] + +[ul] +[*]title: the title of the posting +[*]channel: the channel you want to post to +[*]category: a comma-seperated list of categories for the posting +[*]status: the content of the posting, formatted with BBCode + OR +[*]htmlstatus:the content of the posting, formatted in HTML. +[/ul] + + +Instead of calling [observer.baseurl]/api/statuses/update which returns a json (you could also add .json on the end to clarify) output, you can use [observer.baseurl]/api/statuses/update.xml to get an xml formatted return. + +Instead of Basic HTTP Authentification you could also use oAuth. \ No newline at end of file diff --git a/doc/main.bb b/doc/main.bb index d67c18319..db06071fa 100644 --- a/doc/main.bb +++ b/doc/main.bb @@ -13,7 +13,7 @@ Think of standalone family communication platforms, distributed online communiti Zot is the great new communicaton protocol invented especially for the Red Matrix. As a member you are no longer bound to a single site or hub thanks to "Nomadic Identities". Migrate easily to another server and keep your contacts intact, or clone it and run the same channel on several servers. Just in case one of them might shut down, you don't lose out. Plus once you are inside the Red Matrix there is no need for you to authenticate twice, even when accessing another Red Matrix site. Zot is what sets the Red Matrix apart. [size=large][b]Getting Started[/b][/size] -[zrl=[baseurl]/help/Privacy]Privacy Policy[/zrl] +[zrl=[baseurl]/help/Privacy]Privacy Policy[/zrl] [zrl=[baseurl]/help/registration]Account Registration[/zrl] [zrl=[baseurl]/help/accounts_profiles_channels_basics]You at the Red Matrix: accounts, profiles and channels in short[/zrl] [zrl=[baseurl]/help/profiles]Profiles[/zrl] @@ -58,6 +58,7 @@ Zot is the great new communicaton protocol invented especially for the Red Matri [zrl=[baseurl]/help/developers]Developers[/zrl] [zrl=[baseurl]/help/intro_for_developers]Intro for Developers[/zrl] [zrl=[baseurl]/help/api_functions]API functions[/zrl] +[zrl=[baseurl]/help/api_posting]Posting to the red# using the API[/zrl] [zrl=[baseurl]/help/developer_function_primer]Red Functions 101[/zrl] [zrl=[baseurl]/doc/html/]Code Reference (doxygen generated - sets cookies)[/zrl] [zrl=[baseurl]/help/to_do_doco]To-Do list for the Red Documentation Project[/zrl] -- cgit v1.2.3 From bac1ed221472fae1ff86bd4091a341b2870ab941 Mon Sep 17 00:00:00 2001 From: tonnerkiller Date: Sat, 16 Aug 2014 15:48:44 +0200 Subject: Added "if(!function_exists('xpost_to_html2bbcode'))" This function name is also used by post to friendica plugin Both functions seem to be identical. If you have both plugins installed you get an error because of the identical function name This will avoid the attempt to load the function a second time in case it was already loaded by the post to friendica plugin --- util/wp/post_to_red/post_to_red.php | 132 +++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 64 deletions(-) diff --git a/util/wp/post_to_red/post_to_red.php b/util/wp/post_to_red/post_to_red.php index 5146b8be1..ea6026ae2 100644 --- a/util/wp/post_to_red/post_to_red.php +++ b/util/wp/post_to_red/post_to_red.php @@ -418,72 +418,76 @@ function post_to_red_get_avatar($avatar,$id_or_email,$size,$default,$alt) { // from: // http://www.docgate.com/tutorial/php/how-to-convert-html-to-bbcode-with-php-script.html -function xpost_to_html2bbcode($text) { - $htmltags = array( - '/\(.*?)\<\/b\>/is', - '/\(.*?)\<\/i\>/is', - '/\(.*?)\<\/u\>/is', - '/\(.*?)\<\/ul\>/is', - '/\(.*?)\<\/li\>/is', - '/\/is', // some smiley - '/\/is', - '/\/is', // some smiley - '/\
(.*?)\<\/div\>/is', - '/\
(.*?)\<\/div\>/is', - '/\
(.*?)\<\/div\>/is', - '/\
(.*?)\<\/div\>/is', - '/\(.*?)\<\/cite\>/is', - '/\(.*?)\<\/blockquote\>/is', - '/\(.*?)\<\/div\>/is', - '/\(.*?)\<\/code\>/is', - '/\/is', - '/\(.*?)\<\/strong\>/is', - '/\(.*?)\<\/em\>/is', - '/\(.*?)\<\/a\>/is', - '/\http:\/\/(.*?)\<\/a\>/is', - '/\(.*?)\<\/a\>/is' - ); - - $bbtags = array( - '[b]$1[/b]', - '[i]$1[/i]', - '[u]$1[/u]', - '[list]$1[/list]', - '[*]$1', - '$3', - '[img]http://$2[/img]' . "\n", - ':$3', - '[quote]$1[/quote]', - '[code]$1[/code]', - '', - '', - '', - '[quote]$1[/quote]', - '$1', - '[code]$1[/code]', - "\n", - '[b]$1[/b]', - '[i]$1[/i]', - '[email=$1]$3[/email]', - '[url]$1[/url]', - '[url=$1]$3[/url]' - ); - - $text = str_replace ("\n", ' ', $text); - $ntext = preg_replace ($htmltags, $bbtags, $text); - $ntext = preg_replace ($htmltags, $bbtags, $ntext); - - // for too large text and cannot handle by str_replace - if (!$ntext) { - $ntext = str_replace(array('
', '
'), "\n", $text); - $ntext = str_replace(array('', ''), array('[b]', '[/b]'), $ntext); - $ntext = str_replace(array('', ''), array('[i]', '[/i]'), $ntext); - } - $ntext = strip_tags($ntext); +//function exists also in post to friendica plugin; load only if not yet loaded by that plugin +if(!function_exists('xpost_to_html2bbcode')) { + function xpost_to_html2bbcode($text) { + $htmltags = array( + '/\(.*?)\<\/b\>/is', + '/\(.*?)\<\/i\>/is', + '/\(.*?)\<\/u\>/is', + '/\(.*?)\<\/ul\>/is', + '/\(.*?)\<\/li\>/is', + '/\/is', // some smiley + '/\/is', + '/\/is', // some smiley + '/\