We are in the process of starting over. This means that the entire board at phpbbmodders.net has been set to read-only. All phpBB 2.x and 3.0.x content should be visible but read-only. Private messaging has been disabled for registered users. Registrations will be opened in the near future at the new site. A link to the new site is provided below.

- bonelifer, Administrator

mChat add message

Support for mods released by phpbbmodders.net found at either https://github.com/phpbbmodders/ or the MODDB at http://www.phpbb.com
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
deejay_xb
Member
Member
Posts: 87
Joined: 03 Apr 2011, 06:29

Re: mChat add message

Post by deejay_xb »

do i need to send also some session id?
like mchat.php?sid=dsahfkah114143mhaafa&mode=add&......
Image
User avatar
tumba25
Past Contributor
Past Contributor
Posts: 1049
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Re: mChat add message

Post by tumba25 »

deejay_xb wrote:do i need to send also some session id?
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
Member
Member
Posts: 87
Joined: 03 Apr 2011, 06:29

Re: mChat add message

Post by deejay_xb »

doesnt work..
when posting message it says that i'm not logged in, but i am..

@rich - can you please help? :D
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..
Image
deejay_xb
Member
Member
Posts: 87
Joined: 03 Apr 2011, 06:29

Re: mChat add message

Post by deejay_xb »

nevermid my previous messages i've succeded in postin mchat message from outside :D
Image
User avatar
tumba25
Past Contributor
Past Contributor
Posts: 1049
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Re: mChat add message

Post by tumba25 »

Great. Want to share the needed info?
deejay_xb
Member
Member
Posts: 87
Joined: 03 Apr 2011, 06:29

Re: mChat add message

Post by deejay_xb »

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?
Image
User avatar
tumba25
Past Contributor
Past Contributor
Posts: 1049
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Re: mChat add message

Post by tumba25 »

deejay_xb wrote:i made a custom login.php
So this was not possible without modifying forum files. Maybe should poke Rich about making a API.
deejay_xb
Member
Member
Posts: 87
Joined: 03 Apr 2011, 06:29

Re: mChat add message

Post by deejay_xb »

here is the custom login..
this returns all the needed info for mchat post from outside client :D

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 :(';
?>
Image
User avatar
RMcGirr83
Past Contributor
Past Contributor
Posts: 6242
Joined: 30 Nov 2006, 14:23
Real name: Rich McGirr

Re: mChat add message

Post by RMcGirr83 »

Rich will not be making an API for a mod that isn't going to get ported to 3.1.
User avatar
tumba25
Past Contributor
Past Contributor
Posts: 1049
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Re: mChat add message

Post by tumba25 »

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?
deejay_xb
Member
Member
Posts: 87
Joined: 03 Apr 2011, 06:29

Re: mChat add message

Post by deejay_xb »

the app will be available on google play when it will be ready.
Image

Who is online

Users browsing this forum: CommonCrawl [Bot], Majestic-12 [Bot] and 1 guest