0 favourites
  • 4 posts
  • Can someone help me out please, Im trying to execute this API. it can be used with multiple languages, Including javascript and PHP, so im trying to use it, because surely it works with construct2 right?

    But when using the ajax, i test for a error, and i get one. Nothing specific, just using the AJAX on error event, set text to 'error'.

    Well here is the PHP -

    // Submit those variables to the server

    $post_data = array(

        'api_key' => 'f2eb0260b6073a40f4b0b128a66709aaebbeb754',

        'game_id' => 'Rf2x0WpI8',

        'response' => 'JSON'


    // Send a request to example.com

    $result = post_request('https://www.scoreoid.com/api/getNotification', $post_data);

    if ($result['status'] == 'ok'){

        // Print headers

        echo $result['header'];

        echo '<hr />';

        // print the result of the whole request:

        echo $result['content'];


    else {

        echo 'A error occured: ' . $result['error'];


    I Also tried to use the javascript version, using the callJS plugin, But I do not know what to call, $.post?

    $.post("https://www.scoreoid.com/api/getNotification", { api_key: "f2eb0260b6073a40f4b0b128a66709aaebbeb754", game_id: "Rf2x0WpI8", response: "JSON"},

       function(data) {

         alert("Data Loaded: " + data);




  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • First, does your php script works?

    Do you get the header and content from scoreoid.com/api/getNotification as expected?

    If yes, I think you just have to do a

    System: start of layout
        -> AJAX: Request"http://yourdomain/blahblah/yourphpscript.php" (tag:"call")
    AJAX: On "call" completed
        -> Text: set text to AJAX.LastData
    AJAX: On "call" error
        -> Text: set text to "An error happened."

    Also you might want to replace

    if ($result['status'] == 'ok')
        echo $result['header']; 
        echo '<hr />';
        echo $result['content'];


    if ($result['status'] == 'ok')
        echo $result['header']."\n".$result['content'];

    As Construct2 won't parse the HR element.

  • $.post is jQuery, so make sure you include the jQuery.js file, if you want to use it :)

    Have you tried testing the JS in a seperate HTML file yet? I also highly recommend to use a browser (Chrome)/extension (Firebug for Firefox) with a console, so that you can see what the AJAX post returns to you.

  • The output is still error..

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)