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
Contact:

mChat add message

Post by deejay_xb »

I'm trying to make an android app that connects to mchat, displays messages and user can post message after login.
I can get the messages from mchat but for posting the link is something like this:
/mchat.php?mode=add&message=testtestest&addbbcode20=100&addbbcode_custom=%23&creation_time=1421350220&form_token=cc82asdadsa122141faac5c4493aa220fe57

as i've seen the creation_time is unix current time and the form_token is somehow generated at each message.

If so how can i generate that form_token, what is it based of, sessionid+time, or what?

if i am wrong then please tell me if there is some solution to post message in mchat from outside..
Image
User avatar
tumba25
Supporter
Supporter
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.
Contact:

Re: mChat add message

Post by tumba25 »

form_token is generated like.

Code: Select all

$token = time();
$token .= $user->data['user_form_salt']; // From phpbb_users table.
$token .= $form_name;
$token .= $user->data['session_id']; // from phpbb_sessions table
$form_token = sha1($token);
Since I assume users have to login to be able to post to mChat they need to login though your app. And once that is done you should have access to the user data. You need to send the session_id with each request or the user gets logged out (sid=a442ebde032e9f59dc6fd741bd3ed42a).
deejay_xb
Member
Member
Posts: 87
Joined: 03 Apr 2011, 06:29
Contact:

Re: mChat add message

Post by deejay_xb »

Code: Select all

$token .= $form_name;
and this is what value?
Image
User avatar
tumba25
Supporter
Supporter
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.
Contact:

Re: mChat add message

Post by tumba25 »

You have to look in the mChat sources or the page source of a site running mChat for that value. You are looking for something like <form name="my-form".
deejay_xb
Member
Member
Posts: 87
Joined: 03 Apr 2011, 06:29
Contact:

Re: mChat add message

Post by deejay_xb »

so to summarize:

i need to make a custom login.php, make a reguest from the android app to mysite/login.php with user credentials, if login is succes then login.php has to return the following values:

Code: Select all

$username
$username_clean
$user_id
$user->data['session_id']
$user->data['user_form_salt']
$form_name
with this values then in android app i can generate the form_token for mchat and the user can send a message to mchat..

am i right? any sugestions?
Image
User avatar
tumba25
Supporter
Supporter
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.
Contact:

Re: mChat add message

Post by tumba25 »

login.php don't exist. It is ucp.php?mode=login. Unless you create it and ship it with your app. And those values are not returned by default, you need to query for them when you have a user id and a session id.
deejay_xb
Member
Member
Posts: 87
Joined: 03 Apr 2011, 06:29
Contact:

Re: mChat add message

Post by deejay_xb »

login.php will be a new custom php file in root of my site.
tumba25 wrote:you need to query for them when you have a user id and a session id.
so after login i have to query another file to get those values?
thers no solution to have those values returned in login.php?
Image
User avatar
tumba25
Supporter
Supporter
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.
Contact:

Re: mChat add message

Post by tumba25 »

If login.php is a custom made file for your board you can have it return what you want. I would suggest returning a json encoded array.
deejay_xb
Member
Member
Posts: 87
Joined: 03 Apr 2011, 06:29
Contact:

Re: mChat add message

Post by deejay_xb »

i've made a test:

manually created token:

Code: Select all

time() = 1421591728
user_form_salt = 68cb19d150c03331
form_name = postform
user_session_id = 866c119c443d2828691acc126bb92291
normaltoken = 142159172868cb19d150c03331postform866c119c443d2828691acc126bb92291
sh1_form_token = 4ace9765617adc3af69094eda296244f617bdef5
mchat created token

Code: Select all

form_token = 379ad196d7b4b446d96b882f3ce231ddb50a90fc
they are different.. so what am i doing wrong?
Image
User avatar
tumba25
Supporter
Supporter
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.
Contact:

Re: mChat add message

Post by tumba25 »

time() might differ?
I had a quick look in mChat files and could not find any form name there only form id. That is not the same thing. Maybe try to leave that empty?
deejay_xb
Member
Member
Posts: 87
Joined: 03 Apr 2011, 06:29
Contact:

Re: mChat add message

Post by deejay_xb »

time() is the same, i've used the time() from the mchat autogenerated url
also i put form_name empty but also got different sha1..
Image
User avatar
tumba25
Supporter
Supporter
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.
Contact:

Re: mChat add message

Post by tumba25 »

I should probably install mChat somewhere here.
deejay_xb
Member
Member
Posts: 87
Joined: 03 Apr 2011, 06:29
Contact:

Re: mChat add message

Post by deejay_xb »

cool, then we can make some tests also here :D
Image
User avatar
tumba25
Supporter
Supporter
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.
Contact:

Re: mChat add message

Post by tumba25 »

deejay_xb wrote:cool, then we can make some tests also here :D
Yes, but at this point I need to ask. What kind of license are you planning for your app?
Open source and some free license or closed source and a proprietary license?
deejay_xb
Member
Member
Posts: 87
Joined: 03 Apr 2011, 06:29
Contact:

Re: mChat add message

Post by deejay_xb »

IF the app will work then it will be a free app.
for now to start and develop the app i need to figure out how to make the generated add mchat link..
Image
Post Reply