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
mChat add message
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..
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..
- tumba25
- Supporter
- Posts: 1058
- Joined: 24 Oct 2007, 13:10
- Real name: Jari Kanerva
- Location: Kokkola, Finland.
- Contact:
Re: mChat add message
form_token is generated like.
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).
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);
- tumba25
- Supporter
- Posts: 1058
- Joined: 24 Oct 2007, 13:10
- Real name: Jari Kanerva
- Location: Kokkola, Finland.
- Contact:
Re: mChat add message
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".
Re: mChat add message
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:
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?
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
am i right? any sugestions?
- tumba25
- Supporter
- Posts: 1058
- Joined: 24 Oct 2007, 13:10
- Real name: Jari Kanerva
- Location: Kokkola, Finland.
- Contact:
Re: mChat add message
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.
Re: mChat add message
login.php will be a new custom php file in root of my site.
thers no solution to have those values returned in login.php?
so after login i have to query another file to get those values?tumba25 wrote:you need to query for them when you have a user id and a session id.
thers no solution to have those values returned in login.php?
- tumba25
- Supporter
- Posts: 1058
- Joined: 24 Oct 2007, 13:10
- Real name: Jari Kanerva
- Location: Kokkola, Finland.
- Contact:
Re: mChat add message
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.
Re: mChat add message
i've made a test:
manually created token:
mchat created token
they are different.. so what am i doing wrong?
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
Code: Select all
form_token = 379ad196d7b4b446d96b882f3ce231ddb50a90fc
- tumba25
- Supporter
- Posts: 1058
- Joined: 24 Oct 2007, 13:10
- Real name: Jari Kanerva
- Location: Kokkola, Finland.
- Contact:
Re: mChat add message
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?
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?
Re: mChat add message
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..
also i put form_name empty but also got different sha1..
- tumba25
- Supporter
- Posts: 1058
- Joined: 24 Oct 2007, 13:10
- Real name: Jari Kanerva
- Location: Kokkola, Finland.
- Contact:
Re: mChat add message
I should probably install mChat somewhere here.
- tumba25
- Supporter
- Posts: 1058
- Joined: 24 Oct 2007, 13:10
- Real name: Jari Kanerva
- Location: Kokkola, Finland.
- Contact:
Re: mChat add message
Yes, but at this point I need to ask. What kind of license are you planning for your app?deejay_xb wrote:cool, then we can make some tests also here
Open source and some free license or closed source and a proprietary license?
Re: mChat add message
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..
for now to start and develop the app i need to figure out how to make the generated add mchat link..