mirror of
https://github.com/friendica/friendica
synced 2025-04-27 13:50:12 +00:00
api post sort of working - output status,user need to be swapped
This commit is contained in:
parent
cc7c72be90
commit
b56e00c7c5
4 changed files with 67 additions and 5 deletions
|
@ -27,10 +27,21 @@
|
|||
* Simple HTTP Login
|
||||
*/
|
||||
function api_login(&$a){
|
||||
// workaround for HTTP-auth in CGI mode
|
||||
if(x($_SERVER,'REDIRECT_REMOTE_USER')) {
|
||||
$userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"],6)) ;
|
||||
if(strlen($userpass)) {
|
||||
list($name, $password) = explode(':', $userpass);
|
||||
$_SERVER['PHP_AUTH_USER'] = $name;
|
||||
$_SERVER['PHP_AUTH_PW'] = $password;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($_SERVER['PHP_AUTH_USER'])) {
|
||||
logger('API_login: ' . print_r($_SERVER,true), LOGGER_DEBUG);
|
||||
header('WWW-Authenticate: Basic realm="Friendika"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
die('This api require login');
|
||||
die('This api requires login');
|
||||
}
|
||||
|
||||
$user = $_SERVER['PHP_AUTH_USER'];
|
||||
|
@ -52,9 +63,10 @@
|
|||
if(count($r)){
|
||||
$record = $r[0];
|
||||
} else {
|
||||
logger('API_login failure: ' . print_r($_SERVER,true), LOGGER_DEBUG);
|
||||
header('WWW-Authenticate: Basic realm="Friendika"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
die('This api require login');
|
||||
die('This api requires login');
|
||||
}
|
||||
$_SESSION['uid'] = $record['uid'];
|
||||
$_SESSION['theme'] = $record['theme'];
|
||||
|
@ -303,7 +315,7 @@
|
|||
|
||||
// TODO - media uploads and alternate 'source'
|
||||
|
||||
function api_post_message(&$a, $type) {
|
||||
function api_statuses_update(&$a, $type) {
|
||||
if (local_user()===false) return false;
|
||||
$user_info = api_get_user($a);
|
||||
|
||||
|
@ -329,7 +341,7 @@
|
|||
item_post($a);
|
||||
|
||||
// this should output the last post (the one we just posted).
|
||||
return api_users_show();
|
||||
return api_users_show($a,$type);
|
||||
}
|
||||
api_register_func('api/statuses/update','api_statuses_update', true);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue