Jump to content

REST API: /cms/records/{database_id}


Jarrod Davis

Recommended Posts

Is it possible to set the perPage value? It seem to default to 25. I need it to be something like 10 in one case and 50 in another. I'm attempting to make an online highscore feature for my game projects. I finally figured out how to create/display a database record via REST, now just trying to get all these little nagging issues resolved so I can come up with a working solution. I guess I would need to make a custom template to display the data. That is the next step to figure out, sigh. How to make custom templates. Any way, if anyone has any advice on how best to do what I'm trying to do, would be most appreciated.

Thanks.

Link to comment
Share on other sites

  • 2 weeks later...

Welp, in the end. I had to use a different method, but I think I finally got some results. I ended up using a separate MySQL database and php script to submit/retrieve the scores. This scripts returns JSON data so I created a PHP block to grab this data and display using IPS CSS. 

ips_page_hiscores.png 

Link to comment
Share on other sites

So, the next thing I wanted to do is have the score auto-refresh after a certain time. The scores will be in a section of the page and I did not want the whole page to refresh, so I came up with this change to make that work:

1. Take the Score block from above and put it in render_score.php

2. Create an HTML block with the following code and add this to your page:

<script>
$(document).ready(function(){
  
  setInterval(function(){
    $("#scores").load('/scores/render_score.php')
  }, 30000);
  
  $("#scores").load('/scores/render_score.php');
});
  
</script>
<div id="scores"></div>

It will display the score after the page load, then the "scores" div will refresh.

Link to comment
Share on other sites

Hi, thanks for the reply. Hmm... I wish I had discovered this about a week ago. Haha. I purchased IPS to power my indie game dev studio. It seem to be able to do all that we need in one package. That was appealing to me. I had been thinking about how I wanted to implement the online high score and discovered the REST API and figured ok maybe I can use this. I've only had the software a few weeks now and slowly been learning how to use these type of features. I just discovered the CSS stuff and the above takes advantage of that. 

What I need is:

1. The game needs to be able to send/get scores via HTTP GET/POST
2. Those scores can be viewed on a webpage and they can auto-refresh, but just in the section they are display in.

The original idea was maybe I can use REST and then create a template to display the data. The problem has been learning about how IPS works to be able to do all of that. Honestly I've just been lost in figuring out IPS backend and asking question and getting any kind of response has been slow going. Most of the time all I would need is just a simple example and I can then take that and run with it. The only REST example I could find was the only one in guides and from that I was able to get working what I originally had. I was told to post in the forums for help and, hehe, you are the only person that has even responded. 

Are using those classes fast? I mean do they trigger all the events that is normally triggered if you using REST? Using REST took 3 calls and all the data it returns was a huge overhead and not needed. So think 100s of people posting scores all around the world at the same time. I did not find a way to get the data back sorted by a custom field so I would have to sort on my end, and in that time someone else could have made a post and now what I have in memory waiting to updated would be invalid. So I gave up on trying to use REST. Using those classe can I directly access the database and update the records? Are there any simple examples of their use? Are there any docs for these classes?

Thanks.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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