Merge pull request #566 from tonnerkiller/master
Posting by API and Wordpress plugin
This commit is contained in:
commit
33d43a2a64
23
doc/api_posting.bb
Normal file
23
doc/api_posting.bb
Normal file
@ -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.
|
@ -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]
|
||||
|
@ -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\>(.*?)\<\/b\>/is',
|
||||
'/\<i\>(.*?)\<\/i\>/is',
|
||||
'/\<u\>(.*?)\<\/u\>/is',
|
||||
'/\<ul.*?\>(.*?)\<\/ul\>/is',
|
||||
'/\<li\>(.*?)\<\/li\>/is',
|
||||
'/\<img(.*?) src=\"(.*?)\" alt=\"(.*?)\" title=\"Smile(y?)\" \/\>/is', // some smiley
|
||||
'/\<img(.*?) src=\"http:\/\/(.*?)\" (.*?)\>/is',
|
||||
'/\<img(.*?) src=\"(.*?)\" alt=\":(.*?)\" .*? \/\>/is', // some smiley
|
||||
'/\<div class=\"quotecontent\"\>(.*?)\<\/div\>/is',
|
||||
'/\<div class=\"codecontent\"\>(.*?)\<\/div\>/is',
|
||||
'/\<div class=\"quotetitle\"\>(.*?)\<\/div\>/is',
|
||||
'/\<div class=\"codetitle\"\>(.*?)\<\/div\>/is',
|
||||
'/\<cite.*?\>(.*?)\<\/cite\>/is',
|
||||
'/\<blockquote.*?\>(.*?)\<\/blockquote\>/is',
|
||||
'/\<div\>(.*?)\<\/div\>/is',
|
||||
'/\<code\>(.*?)\<\/code\>/is',
|
||||
'/\<br(.*?)\>/is',
|
||||
'/\<strong\>(.*?)\<\/strong\>/is',
|
||||
'/\<em\>(.*?)\<\/em\>/is',
|
||||
'/\<a href=\"mailto:(.*?)\"(.*?)\>(.*?)\<\/a\>/is',
|
||||
'/\<a .*?href=\"(.*?)\"(.*?)\>http:\/\/(.*?)\<\/a\>/is',
|
||||
'/\<a .*?href=\"(.*?)\"(.*?)\>(.*?)\<\/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]'
|
||||
);
|
||||
//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\>(.*?)\<\/b\>/is',
|
||||
'/\<i\>(.*?)\<\/i\>/is',
|
||||
'/\<u\>(.*?)\<\/u\>/is',
|
||||
'/\<ul.*?\>(.*?)\<\/ul\>/is',
|
||||
'/\<li\>(.*?)\<\/li\>/is',
|
||||
'/\<img(.*?) src=\"(.*?)\" alt=\"(.*?)\" title=\"Smile(y?)\" \/\>/is', // some smiley
|
||||
'/\<img(.*?) src=\"http:\/\/(.*?)\" (.*?)\>/is',
|
||||
'/\<img(.*?) src=\"(.*?)\" alt=\":(.*?)\" .*? \/\>/is', // some smiley
|
||||
'/\<div class=\"quotecontent\"\>(.*?)\<\/div\>/is',
|
||||
'/\<div class=\"codecontent\"\>(.*?)\<\/div\>/is',
|
||||
'/\<div class=\"quotetitle\"\>(.*?)\<\/div\>/is',
|
||||
'/\<div class=\"codetitle\"\>(.*?)\<\/div\>/is',
|
||||
'/\<cite.*?\>(.*?)\<\/cite\>/is',
|
||||
'/\<blockquote.*?\>(.*?)\<\/blockquote\>/is',
|
||||
'/\<div\>(.*?)\<\/div\>/is',
|
||||
'/\<code\>(.*?)\<\/code\>/is',
|
||||
'/\<br(.*?)\>/is',
|
||||
'/\<strong\>(.*?)\<\/strong\>/is',
|
||||
'/\<em\>(.*?)\<\/em\>/is',
|
||||
'/\<a href=\"mailto:(.*?)\"(.*?)\>(.*?)\<\/a\>/is',
|
||||
'/\<a .*?href=\"(.*?)\"(.*?)\>http:\/\/(.*?)\<\/a\>/is',
|
||||
'/\<a .*?href=\"(.*?)\"(.*?)\>(.*?)\<\/a\>/is'
|
||||
);
|
||||
|
||||
$text = str_replace ("\n", ' ', $text);
|
||||
$ntext = preg_replace ($htmltags, $bbtags, $text);
|
||||
$ntext = preg_replace ($htmltags, $bbtags, $ntext);
|
||||
$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]'
|
||||
);
|
||||
|
||||
// for too large text and cannot handle by str_replace
|
||||
if (!$ntext) {
|
||||
$ntext = str_replace(array('<br>', '<br />'), "\n", $text);
|
||||
$ntext = str_replace(array('<strong>', '</strong>'), array('[b]', '[/b]'), $ntext);
|
||||
$ntext = str_replace(array('<em>', '</em>'), array('[i]', '[/i]'), $ntext);
|
||||
$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('<br>', '<br />'), "\n", $text);
|
||||
$ntext = str_replace(array('<strong>', '</strong>'), array('[b]', '[/b]'), $ntext);
|
||||
$ntext = str_replace(array('<em>', '</em>'), array('[i]', '[/i]'), $ntext);
|
||||
}
|
||||
|
||||
$ntext = strip_tags($ntext);
|
||||
|
||||
$ntext = trim(html_entity_decode($ntext,ENT_QUOTES,'UTF-8'));
|
||||
return $ntext;
|
||||
}
|
||||
|
||||
$ntext = strip_tags($ntext);
|
||||
|
||||
$ntext = trim(html_entity_decode($ntext,ENT_QUOTES,'UTF-8'));
|
||||
return $ntext;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user