Jump to content

Documentation on how IPS message is created?


PinPics

Recommended Posts

Not sure if this is the correct place to post this. Please move if that's better.

I'm absolutely thrilled with IPS and what it is opening up for our site, and I'd like to move all messaging to the IPS software.

Currently, my developer has created an area in our pin trading database where members can select a pin(s) to make a trade offer with another member. He has a small text box come up where the member can write a note, and then that generates a started message in the sort of chat system we are subscribed to now. We'd like it to generate a message in the IPS inbox. Is there some documentation on how a message is created in IPS? That way, my developer may be able to do this?

Thanks a lot!

Link to comment
Share on other sites

My developer is working on this, and he sent me this to ask here:

So it looks like in the documentation it’s wanting me to submit to a URL similar to this:  https://forum.pinpics.com/api/core/messages 

When I try that, I get a 404 (page not found).  I’m thinking it’s because friendly URLs or mod_rewrite isn’t on for the site but I’m not sure if that’s it.  Can you reach out to support and see if I’m submitting to the accurate place? 

I can give them a snippet of code if they want to review.

 

I did go inside the AdminCP and check, and it appears we do have friendly URLs enabled, but maybe not in the right place?

Could contain: File, Page, Text, Webpage

Edited by PinPics
Link to comment
Share on other sites

Since you have Friendly URLs disabled, your developer needs to use this URL instead:

https://forum.pinpics.com/api/index.php?/core/messages 

 

I suggest enabling FURLs on the server, though. The URLs will look cleaner and will be easier to read. Also, Friendly URLs will be a requirement in v5: 

 

It would be best to enable them now and also have the links indexed by search engines with that format from the start.

Link to comment
Share on other sites

55 minutes ago, teraßyte said:

Since you have Friendly URLs disabled, your developer needs to use this URL instead:

https://forum.pinpics.com/api/index.php?/core/messages 

 

I suggest enabling FURLs on the server, though. The URLs will look cleaner and will be easier to read. Also, Friendly URLs will be a requirement in v5: 

 

It would be best to enable them now and also have the links indexed by search engines with that format from the start.

 

Thank you so much! We definitely want to be preparing for v5!
I thought we did have Friendly URLs enabled:

Could contain: File, Page, Text, Webpage

Do we need to enable them somewhere else? That's a good idea about the indexing, and I'm glad this came up. As of now, we're not open to Google and have not been indexed, but hoping to get open by next week!

Link to comment
Share on other sites

The second setting Rewrite URLs? in your screenshot is disabled. When that setting is disabled all your URLs will contain the index.php?/ part I added above for the API URL.

 

Enabling the setting and uploading the required .htaccess file will get rid of that part. And the original API URL in the documentation will work without having to use the updated URL I provided in my previous reply.

Link to comment
Share on other sites

Got the Friendly URLs all taken care of, and they seem to be working. But my developer is still getting a 404 on his API application. He tried with /core/messages as well as /api/core/messages.

Any ideas on this, please? Thanks so much! Sure it's something small, but we're so close! 🙂

Could contain: File, Webpage, Text

Link to comment
Share on other sites

Got an update from my developer, and he's got a couple questions ---

It was the .htaccess that was the issue.  The one we put in yesterday for the pretty URLs is apparently different than the one needed for the API + Pretty URLs, but once I put that in, it broke the site via the browser so I reverted ☹

Could contain: Text, Scoreboard

The good thing is that I got the actual API connected w/the software, but I ran into another issue.  Once I made the call, I got invalid recipient.

Could contain: File, Page, Text, Webpage

Below are the two issues lined out: 

  1. The htaccess file from the API location doesn’t allow both browser and API access (probably an easy fix)
  2. The call once the API htaccess file is up doesn’t send (probably a misunderstanding on my part on how to send).

I used member id 10 and 12 to try to send a test message.

- - - - - -

He says that what he needs is to find out how to get the htaccess file to work with both api and the site so that both are true. He also needs to understand how to send messages, and he thinks that the above writeup and screen grabs help to illustrate the issue.

Thanks in advance for your help! 🙂

Link to comment
Share on other sites

That fixed the API issue perfectly. Thank you!

Just one more thing going on here, I think.

He's trying to get a message to send, but here's what happens:
Could contain: Page, Text, File, Computer Hardware, Electronics, Hardware, Monitor, Screen

It's a valid account though:
Could contain: Computer Hardware, Electronics, Hardware, Monitor, Screen, Text

It's probably something simple, but any suggestions as to what is going wrong?

Link to comment
Share on other sites

Thank you for the above! That fixed the "Invalid Recipient" error . . . but not we've got "Invalid Sender". Probably something simple . . . anymore thoughts? Thank you SO much!!!

This is the code: { "errorCode": "1C374\/2", "errorMessage": "INVALID_SENDER" }

 

Could contain: Page, Text, File

 

Link to comment
Share on other sites

This one, I'm really not sure... This is the code that throws the exception:

		/* Make sure there is a valid sender */
		if ( !isset( \IPS\Request::i()->from ) OR !\IPS\Member::load( (int) \IPS\Request::i()->from )->member_id )
		{
			throw new \IPS\Api\Exception( 'INVALID_SENDER', '1C374/2', 404 );
		}

It gets triggered if the from value is missing, or if there is no member with the specified ID. Based on your screenshot above the member ID 10 exists, though. 🤷‍♂️

 

The funny thing is that this exception is thrown before the other INVALID_RECIPIENT one you posted above. Was the member with ID 10 deleted perhaps? If it was working before, I have no other idea why it doesn't now.

 

EDIT

Taking another look at your last screenshot, I see the from value is being passed as a string rather than an integer:

'from' => '10'

I don't think it will change anything, since the code is casting it as (int), but try changing that row to:

'from' => 10

 

P.S.: You have the session cookie, authorization key, etc., in that screenshot. Probably best if you hide them. (Unless you've already regenerated them after the screenshot).

Link to comment
Share on other sites

7 hours ago, teraßyte said:

This one, I'm really not sure... This is the code that throws the exception:

		/* Make sure there is a valid sender */
		if ( !isset( \IPS\Request::i()->from ) OR !\IPS\Member::load( (int) \IPS\Request::i()->from )->member_id )
		{
			throw new \IPS\Api\Exception( 'INVALID_SENDER', '1C374/2', 404 );
		}

It gets triggered if the from value is missing, or if there is no member with the specified ID. Based on your screenshot above the member ID 10 exists, though. 🤷‍♂️

 

The funny thing is that this exception is thrown before the other INVALID_RECIPIENT one you posted above. Was the member with ID 10 deleted perhaps? If it was working before, I have no other idea why it doesn't now.

 

EDIT

Taking another look at your last screenshot, I see the from value is being passed as a string rather than an integer:

'from' => '10'

I don't think it will change anything, since the code is casting it as (int), but try changing that row to:

'from' => 10

 

P.S.: You have the session cookie, authorization key, etc., in that screenshot. Probably best if you hide them. (Unless you've already regenerated them after the screenshot).

My developer says he did try the number change before asking, but it gives this error:

Could contain: File, Page, Text, Computer, Electronics, Pc, Hardware, Monitor, Screen, Webpage

Any thoughts? We're so close! 🙂

Link to comment
Share on other sites

Sorry, I have nothing else right now. Maybe someone else will be able to spot something I missed. 🤷‍♂️

 

Out of curiosity, if your developer goes back and tries the code that was giving the first exception, what does he get now? In theory, he should still get the latest exception (since it triggers before the invalid recipient one):

{ "errorCode": "1C374\/2", "errorMessage": "INVALID_SENDER" }

But I'm wondering if he still gets the other one instead:

{ "errorCode": "1C374\/3", "errorMessage": "INVALID_RECIPIENT" }

 

I'm talking about this post => https://invisioncommunity.com/forums/topic/475882-documentation-on-how-ips-message-is-created/?do=findComment&comment=2957027

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...