[Solved] Making an App, need help with PHPBB Private Messages

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
basstabs
Registered User
Posts: 4
Joined: Tue Jun 20, 2017 3:50 pm

[Solved] Making an App, need help with PHPBB Private Messages

Post by basstabs »

First off, I'm not sure if this is the right section to post this or not. I looked at the Extension Development section but decided my issue wasn't a proper fit there. Apologies for any confusion.

I'm currently building an Android app which interfaces with a specific installation of PHPBB 3.1 and allows the user to perform limited actions within that board. Notably viewing/sending private messages and retrieving posts from a specific thread. This is achieved using Volley and simply requesting and receiving HTML from the server as one would from a browser, so I'm not directly touching the database or backend in any way that a normal user would not, in theory at least.

Currently all of the desired core features work except sending private messages. Using the broswer's network tab, I deconstructed the "Compose" page and figured out what parameters and such needed to be sent in with the form. Currently I request the Compose page and extract the Sid. Then I use the add function to retrieve the desired user's id for sending the message. After retrieving this and the new Sid, I build a POST request to try and send the message. I set all of the parameters that I can see in Firefox. The problem is, while the message sends normally in the browser, it does not send from the app. Instead the response page is just my Inbox page. No error mesages of any sort are displayed. I tried tracking down the logic for this in PHPBB's includes/ucp/ucp_pm_compose.php file, but I couldnt see a place where it redirected to the inbox directly from the submit button. Help figuring out what is causing this would be greatly appreciated :) Let me know if anything needs further clarification.

Also, I asked the board manager and he said the only modification installed that in any way affects the behavior of PMs is the PM Search mod, version 1.03.
Last edited by basstabs on Thu Jun 29, 2017 7:15 am, edited 1 time in total.
basstabs
Registered User
Posts: 4
Joined: Tue Jun 20, 2017 3:50 pm

Re: Making an App, need help with PHPBB Private Messages

Post by basstabs »

Since it doesn't appear that anyone has the information I'm looking for, does anyone have recommendations on where I could go to find the answer? Thanks~ :)
User avatar
Ger
Registered User
Posts: 2108
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Making an App, need help with PHPBB Private Messages

Post by Ger »

Do you have the form_key added?
https://wiki.phpbb.com/Function.add_form_key

Also note that after a successfully sent PM, you'll be redirected to the inbox page IIRC.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:

-Don't PM me for support-
basstabs
Registered User
Posts: 4
Joined: Tue Jun 20, 2017 3:50 pm

Re: Making an App, need help with PHPBB Private Messages

Post by basstabs »

I have the form_token added, is the form_key separate from that? Looking at the parameters in Firefox's network tab I do not see a form_key parameter when successfully sending a message. Currently the process works as follows:

Send a request for the compose page >
Extract the form_token from the returned page >
Send a POST to use the "add" feature to turn a string username into a user id >
Extract the user id and form_token from the response >
Send a request with all parameters set to try and send the PM.

This last step returns no warnings and returns the Inbox page, but the message is never sent.

So I am aware that the page is redirected to the inbox after a message is successfully sent, but I can verify that messages sent from the app are not sent by logging into my account and checking my sent/outbox folders. The messages seem to not be created at all and never stored in the database, but there are no error messages telling me why.
User avatar
Ger
Registered User
Posts: 2108
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Making an App, need help with PHPBB Private Messages

Post by Ger »

Might be a $lastclick thing... Checkout https://github.com/phpbb/phpbb/blob/mas ... se.php#L83

If your app does this automatically, the $current_time - $lastclick might be smaller than 2.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:

-Don't PM me for support-
basstabs
Registered User
Posts: 4
Joined: Tue Jun 20, 2017 3:50 pm

Re: Making an App, need help with PHPBB Private Messages

Post by basstabs »

Ah, yes, that sounds like it might be the issue. The app sets lastclick and currenttime at the same time, so they're probably the same. I can't work on it right now, but I'll test it tonight and see if it works. That looks like the issue though :) Thanks so much~

Edit: This did indeed fix my issue, I can successfully send messages now. Thank you so much for the help~
Post Reply

Return to “phpBB Custom Coding”