PinPics Posted October 20, 2023 Share Posted October 20, 2023 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 More sharing options...
teraßyte Posted October 20, 2023 Share Posted October 20, 2023 He can use the REST API to create a new personal conversation: https://invisioncommunity.com/developers/rest-api?endpoint=core/messages/POSTindex There are also 2 other APIs to add replies to an existing personal conversation or to delete it entirely. Daniel F 1 Link to comment Share on other sites More sharing options...
PinPics Posted October 24, 2023 Author Share Posted October 24, 2023 (edited) 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? Edited October 24, 2023 by PinPics Link to comment Share on other sites More sharing options...
Nathan Explosion Posted October 24, 2023 Share Posted October 24, 2023 Assuming you've set up the API in the ACP, putting the .htaccess file in place, and provided them with an API key? Link to comment Share on other sites More sharing options...
Adriano Faria Posted October 24, 2023 Share Posted October 24, 2023 If it is an app your developer is creating to use on your own site, there's no need to use Rest API. Use the script in your app. Link to comment Share on other sites More sharing options...
teraßyte Posted October 24, 2023 Share Posted October 24, 2023 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. PinPics 1 Link to comment Share on other sites More sharing options...
PinPics Posted October 24, 2023 Author Share Posted October 24, 2023 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: 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 More sharing options...
teraßyte Posted October 24, 2023 Share Posted October 24, 2023 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. PinPics 1 Link to comment Share on other sites More sharing options...
PinPics Posted October 24, 2023 Author Share Posted October 24, 2023 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! 🙂 Link to comment Share on other sites More sharing options...
Nathan Explosion Posted October 24, 2023 Share Posted October 24, 2023 9 hours ago, Nathan Explosion said: Assuming you've set up the API in the ACP, putting the .htaccess file in place, and provided them with an API key? Have you done this? It's not the same as the friendly url stuff. PinPics 1 Link to comment Share on other sites More sharing options...
teraßyte Posted October 24, 2023 Share Posted October 24, 2023 Indeed. Based on your screenshot, there is no API KEY being passed as a parameter. Your developer can read more about it on this page: https://invisioncommunity.com/developers/rest-api PinPics 1 Link to comment Share on other sites More sharing options...
PinPics Posted October 24, 2023 Author Share Posted October 24, 2023 Thanks to both of you! I am passing this on to him right now. 🙂 Link to comment Share on other sites More sharing options...
PinPics Posted October 25, 2023 Author Share Posted October 25, 2023 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 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. Below are the two issues lined out: The htaccess file from the API location doesn’t allow both browser and API access (probably an easy fix) 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 More sharing options...
Nathan Explosion Posted October 25, 2023 Share Posted October 25, 2023 6 minutes ago, PinPics said: htaccess file to work with both api and the site They go in different locations...by any chance, did you put the API one in the root of the site, replacing the one you put in to add support for friendly urls? teraßyte and PinPics 1 1 Link to comment Share on other sites More sharing options...
teraßyte Posted October 25, 2023 Share Posted October 25, 2023 As Nathan said, the htaccess files are different: The htaccess file for friendly/rewrite URLs goes into the root folder (where the conf_global.php file is located). The htaccess file for the API goes into the /api folder. PinPics 1 Link to comment Share on other sites More sharing options...
PinPics Posted October 25, 2023 Author Share Posted October 25, 2023 Thanks again!! Am sending this over now. Really appreciate you guys helping. Link to comment Share on other sites More sharing options...
PinPics Posted October 25, 2023 Author Share Posted October 25, 2023 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: It's a valid account though: It's probably something simple, but any suggestions as to what is going wrong? Link to comment Share on other sites More sharing options...
teraßyte Posted October 26, 2023 Share Posted October 26, 2023 Yup. The problem is that the from value is an integer, but the to value is an array instead and he's passing it as an integer: to array One or more user IDs conversation is sent to Link to comment Share on other sites More sharing options...
PinPics Posted October 26, 2023 Author Share Posted October 26, 2023 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" } Link to comment Share on other sites More sharing options...
teraßyte Posted October 26, 2023 Share Posted October 26, 2023 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). PinPics 1 Link to comment Share on other sites More sharing options...
PinPics Posted October 26, 2023 Author Share Posted October 26, 2023 Thanks! Sending that to the developer now. @Matt @Marc Stridgen @Jim M Is it possible to remove the image in my previous post and replace it with this one? I didn't realize that I forgot to cover some info up in that one. Thanks! Link to comment Share on other sites More sharing options...
Jim M Posted October 26, 2023 Share Posted October 26, 2023 41 minutes ago, PinPics said: Thanks! Sending that to the developer now. @Matt @Marc Stridgen @Jim M Is it possible to remove the image in my previous post and replace it with this one? I didn't realize that I forgot to cover some info up in that one. Thanks! I have gone ahead and done that for you now 🙂 PinPics 1 Link to comment Share on other sites More sharing options...
PinPics Posted October 26, 2023 Author Share Posted October 26, 2023 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: Any thoughts? We're so close! 🙂 Link to comment Share on other sites More sharing options...
teraßyte Posted October 26, 2023 Share Posted October 26, 2023 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 More sharing options...
Recommended Posts