]> git.mxchange.org Git - friendica.git/blob - mod/oexchange.php
First attemp of api
[friendica.git] / mod / oexchange.php
1 <?php
2
3
4 function oexchange_init(&$a) {
5
6         if(($a->argc > 1) && ($a->argv[1] === 'xrd')) {
7                 $tpl = load_view_file('view/oexchange_xrd.tpl');
8
9                 $o = replace_macros($tpl, array('$base' => $a->get_baseurl()));
10                 echo $o;
11                 killme();
12         }
13
14                 
15
16
17 }
18
19 function oexchange_content(&$a) {
20
21         if(! local_user()) {
22                 $o = login(false);
23                 return $o;
24         }
25
26         if(($a->argc > 1) && $a->argv[1] === 'done') {
27                 notice( t('Post successful.') . EOL);
28                 return;
29         }
30
31         $url = (((x($_GET,'url')) && strlen($_GET['url'])) ? notags(trim($_GET['url'])) : '');
32
33         $s = fetch_url($a->get_baseurl() . '/parse_url&url=' . $url);
34
35         if(! strlen($s))
36                 return;
37
38         require_once('include/html2bbcode.php');
39
40         $post = array();
41
42         $post['profile_uid'] = local_user();
43         $post['return'] = '/oexchange/done' ;
44         $post['body'] = html2bbcode($s);
45         $post['type'] = 'wall';
46
47         $_POST = $post;
48         require_once('mod/item.php');
49         item_post($a);
50
51 }
52
53