From fdd2da905a27fab838aa34ef7baf0ee2c5c3c5f7 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 13 Dec 2015 19:15:42 -0800 Subject: more work on api media uploads --- mod/wall_attach.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'mod/wall_attach.php') diff --git a/mod/wall_attach.php b/mod/wall_attach.php index 8677c2b83..f52a4f2e5 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -6,14 +6,16 @@ require_once('include/photos.php'); function wall_attach_post(&$a) { - if(argc() > 1) - $channel = get_channel_by_nick(argv(1)); - elseif($_FILES['media']) { - require_once('include/api.php'); - $user_info = api_get_user($a); + $using_api = false; + + if($a->data['api_info'] && array_key_exists('media',$_FILES)) { + $using_api = true; + $user_info = $a->data['api_info']; $nick = $user_info['screen_name']; $channel = get_channel_by_nick($user_info['screen_name']); - } + } + elseif(argc() > 1) + $channel = get_channel_by_nick(argv(1)); if(! $channel) killme(); @@ -49,12 +51,16 @@ function wall_attach_post(&$a) { } if(intval($r['data']['is_photo'])) { - echo "\n\n" . $r['body'] . "\n\n"; - if($using_api) - return; - killme(); + $s = "\n\n" . $r['body'] . "\n\n"; + } + else { + $s = "\n\n" . '[attachment]' . $r['data']['hash'] . ',' . $r['data']['revision'] . '[/attachment]' . "\n"; } - echo "\n\n" . '[attachment]' . $r['data']['hash'] . ',' . $r['data']['revision'] . '[/attachment]' . "\n"; + + if($using_api) + return $s; + + echo $s; killme(); } -- cgit v1.2.3