do i need to send also some session id?
like mchat.php?sid=dsahfkah114143mhaafa&mode=add&......
mChat add message
Forum rules
Please only request support for mods released by phpbbmodders.net found at either https://github.com/phpbbmodders/ or the MODDB at http://www.phpbb.com
Please only request support for mods released by phpbbmodders.net found at either https://github.com/phpbbmodders/ or the MODDB at http://www.phpbb.com
- tumba25
- Past Contributor
- Posts: 1058
- Joined: 24 Oct 2007, 13:10
- Real name: Jari Kanerva
- Location: Kokkola, Finland.
Re: mChat add message
That don't hurt. But if you are still logged in after the first request then you don't need to send it as get data.deejay_xb wrote:do i need to send also some session id?
-
- Member
- Posts: 87
- Joined: 03 Apr 2011, 06:29
Re: mChat add message
doesnt work..
when posting message it says that i'm not logged in, but i am..
@rich - can you please help?
why mchat says i'm not logged in but i am logged in in phpbb? how to post message without using cookies? with sid (from users_table) it does not work..
when posting message it says that i'm not logged in, but i am..
@rich - can you please help?

why mchat says i'm not logged in but i am logged in in phpbb? how to post message without using cookies? with sid (from users_table) it does not work..
-
- Member
- Posts: 87
- Joined: 03 Apr 2011, 06:29
Re: mChat add message
nevermid my previous messages i've succeded in postin mchat message from outside 

- tumba25
- Past Contributor
- Posts: 1058
- Joined: 24 Oct 2007, 13:10
- Real name: Jari Kanerva
- Location: Kokkola, Finland.
Re: mChat add message
Great. Want to share the needed info?
-
- Member
- Posts: 87
- Joined: 03 Apr 2011, 06:29
Re: mChat add message
the problem was curl related, and mchat post link is like this:
mchat.php?sid=usersessionid&mode=add&the rest of variables autogenerated like time form_token..
so i made a custom login.php that returns in json format all the variables i need when i login, then with that variables i make the post url and send to mchat. that's all and it works.
do you need any more info?
mchat.php?sid=usersessionid&mode=add&the rest of variables autogenerated like time form_token..
so i made a custom login.php that returns in json format all the variables i need when i login, then with that variables i make the post url and send to mchat. that's all and it works.
do you need any more info?
- tumba25
- Past Contributor
- Posts: 1058
- Joined: 24 Oct 2007, 13:10
- Real name: Jari Kanerva
- Location: Kokkola, Finland.
Re: mChat add message
So this was not possible without modifying forum files. Maybe should poke Rich about making a API.deejay_xb wrote:i made a custom login.php
-
- Member
- Posts: 87
- Joined: 03 Apr 2011, 06:29
Re: mChat add message
here is the custom login..
this returns all the needed info for mchat post from outside client
this returns all the needed info for mchat post from outside client

Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Basic parameter data
$id = request_var('i', '');
$mode = request_var('mode', '');
$result_array = array();
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// Basic "global" modes
switch ($mode)
{
case 'login':
if($user->data['is_registered'])
{
//User is already logged in
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
$result_array['auth'] = 1;
$result_array['user'] = $user->data['username'];
$result_array['userid'] = $user->data['user_id'];
$result_array['usersid'] = $user->data['session_id'];
$result_array['phpsid'] = session_id();
$result_array['time'] = time();
$result_array['userfs'] = $user->data['user_form_salt'];
$result_array['form_name'] = 'mchat_posting';
$result_array['tokensid'] = $token_sid;
}
else
{
//User is NOT logged in and we need to check if correct login credentials
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
$username = request_var('username', '', true);
$password = request_var('password', '', true);
// echo "username: " . $username . " ; password: " . $password;
$result = $auth->login($username, $password);
if ($result['status'] == LOGIN_SUCCESS)
{
//User was successfully logged in phpbb
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
$result_array['auth'] = 1;
$result_array['user'] = $user->data['username'];
$result_array['userid'] = $user->data['user_id'];
$result_array['usersid'] = $user->data['session_id'];
$result_array['phpsid'] = session_id();
$result_array['time'] = time();
$result_array['userfs'] = $user->data['user_form_salt'];
$result_array['form_name'] = 'mchat_posting';
$result_array['tokensid'] = $token_sid;
}
else
{
//login failed..
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
$result_array['auth'] = 3;
$result_array['tokensid'] = $token_sid;
}
};
break;
case 'logout':
if ($user->data['user_id'] != ANONYMOUS && isset($_GET['sid']) && !is_array($_GET['sid']) && $_GET['sid'] === $user->session_id)
{
$user->session_kill();
$user->session_begin();
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
$result_array['auth'] = 2;
$result_array['tokensid'] = $token_sid;
}
else
{
$message = ($user->data['user_id'] == ANONYMOUS) ? $user->lang['LOGOUT_REDIRECT'] : $user->lang['LOGOUT_FAILED'];
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
$result_array['auth'] = 3;
$result_array['tokensid'] = $token_sid;
}
}
//print_r ($result_array);
if(function_exists('json_encode'))
{
header('Content-Type: application/json');
echo json_encode($result_array); //Lastest versions of PHP already has this functionality.
//echo 'json ok';
}
else echo 'no json :(';
?>
- RMcGirr83
- Past Contributor
- Posts: 6243
- Joined: 30 Nov 2006, 14:23
- Real name: Rich McGirr
Re: mChat add message
Rich will not be making an API for a mod that isn't going to get ported to 3.1.
- tumba25
- Past Contributor
- Posts: 1058
- Joined: 24 Oct 2007, 13:10
- Real name: Jari Kanerva
- Location: Kokkola, Finland.
Re: mChat add message
deejay_xb wrote:here is the custom login..
this returns all the needed info for mchat post from outside client
Where can we download the client source code?
-
- Member
- Posts: 87
- Joined: 03 Apr 2011, 06:29
Return to “Modders MOD support”
Who is online
Users browsing this forum: No registered users and 0 guests