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

mChat add message

Postby deejay_xb » 16 Jan 2015, 17:31

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
Past Contributor
Past Contributor
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Re: mChat add message

Postby tumba25 » 16 Jan 2015, 22:15

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

Re: mChat add message

Postby deejay_xb » 17 Jan 2015, 17:24

Code: Select all

$token .= $form_name;


and this is what value?
Image

User avatar
tumba25
Past Contributor
Past Contributor
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Re: mChat add message

Postby tumba25 » 17 Jan 2015, 21:35

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

Re: mChat add message

Postby deejay_xb » 18 Jan 2015, 08:28

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
Past Contributor
Past Contributor
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Re: mChat add message

Postby tumba25 » 18 Jan 2015, 11:13

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

Re: mChat add message

Postby deejay_xb » 18 Jan 2015, 11:19

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
Past Contributor
Past Contributor
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Re: mChat add message

Postby tumba25 » 18 Jan 2015, 12:46

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

Re: mChat add message

Postby deejay_xb » 18 Jan 2015, 14:43

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
Past Contributor
Past Contributor
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Re: mChat add message

Postby tumba25 » 18 Jan 2015, 16:05

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

Re: mChat add message

Postby deejay_xb » 18 Jan 2015, 16:14

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
Past Contributor
Past Contributor
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Re: mChat add message

Postby tumba25 » 19 Jan 2015, 12:51

I should probably install mChat somewhere here.

deejay_xb
Member
Member
Posts: 87
Joined: 03 Apr 2011, 06:29

Re: mChat add message

Postby deejay_xb » 19 Jan 2015, 15:15

cool, then we can make some tests also here :D
Image

User avatar
tumba25
Past Contributor
Past Contributor
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Re: mChat add message

Postby tumba25 » 20 Jan 2015, 07:57

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

Re: mChat add message

Postby deejay_xb » 20 Jan 2015, 08:56

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


Return to “Modders MOD support”

Who is online

Users browsing this forum: CommonCrawl [Bot] and 1 guest