User Tag List

Results 1 to 10 of 10

Thread: Get Object Works in Engine, but Not in HTML5 Runtime w/ Example

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export Module
    Retrobolt's Avatar
    Join Date
    Mar 2016
    Posts
    438
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Get Object Works in Engine, but Not in HTML5 Runtime w/ Example

    I need to pull a value from PHP and it works fine with the GET Object in fusion, but when I build, it doesn't work.

    What's causing this and is there a way around it?

    I linked an example that shows this.

    Thank you

    Get PHP in HTML5 Runtime.mfa

  2. #2
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleMac Export ModuleFirefly 3D Module
    tobydavis's Avatar
    Join Date
    Apr 2019
    Location
    United States
    Posts
    96
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Retrobolt View Post
    I need to pull a value from PHP and it works fine with the GET Object in fusion, but when I build, it doesn't work.

    What's causing this and is there a way around it?

    I linked an example that shows this.

    Thank you

    Get PHP in HTML5 Runtime.mfa
    This isn't an issue with the Get object. It looks like it's an issue with the script you are executing on the server. The Cross-Origin request was blocked because the response data from the PHP script was missing the CORS header 'Access-Control-Allow-Origin'. You need to return this response header with your data so that the request isn't blocked. For example, the Newgrounds.io Gateway address (https://www.newgrounds.io/gateway_v3.php) returns some JSON data instead of rejecting the request because the gateway's PHP script has been set up to allow requests from remote origins. As long as you remember to have your script return that header with the rest of your response data, the GET request to that address from the Get object should work on the HTML5 runtime.

    Some more information on the 'Access-Control-Allow-Origin' header: https://www.freecodecamp.org/news/ac...der-explained/

    Here's how to add that header to a PHP script: https://enable-cors.org/server_php.html
    Images attachées Images attachées

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export Module
    Retrobolt's Avatar
    Join Date
    Mar 2016
    Posts
    438
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank you, someone else is doing the php and they sent me their script listed below. What changes have to be made to it?

    PHP Code:
    <?
    echo "YES";
    ?>

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export Module
    Retrobolt's Avatar
    Join Date
    Mar 2016
    Posts
    438
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Do I just add-

    header("Access-Control-Allow-Origin: *");

  5. #5
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleMac Export ModuleFirefly 3D Module
    tobydavis's Avatar
    Join Date
    Apr 2019
    Location
    United States
    Posts
    96
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Retrobolt View Post
    Do I just add-

    header("Access-Control-Allow-Origin: *");
    Yes you should add that. Make sure that line is at the very top of the script before anything else. Like this:

    Code:
    <?php
    header("Access-Control-Allow-Origin: *");
    echo "YES"; 
    ?>
    I tested this exact code on my own site and can confirm that it works.

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export Module
    Retrobolt's Avatar
    Join Date
    Mar 2016
    Posts
    438
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    What site can I go to for free hosting so I can test out this php script?
    Thanks

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export Module
    Retrobolt's Avatar
    Join Date
    Mar 2016
    Posts
    438
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I added it to the php scripts and the .htaccess file, it's still not working.

    Here's a link to the new version- http://form1generator.com/V8/

  8. #8
    Clickteam Clickteam
    Fernando's Avatar
    Join Date
    Dec 2006
    Posts
    7,553
    Mentioned
    298 Post(s)
    Tagged
    4 Thread(s)
    You should also post errors from console to have a better understanding,

    starting from this:

    Cookie “PHPSESSID” does not have a proper “SameSite” attribute value. Soon, cookies without the “SameSite” attribute or with an invalid value will be treated as “Lax”. This means that the cookie will no longer be sent in third-party contexts. If your application depends on this cookie being available in such contexts, please add the “SameSite=None“ attribute to it. To know more about the “SameSite“ attribute, read https://developer.mozilla.org/docs/W...ookie/SameSite

    If you are planning to need this, it is very important to set up correctly.

    Then i played a little bit with your website and moving ahead i got another error


    GET http://form1generator.com/favicon.ico
    [HTTP/1.1 404 Not Found 0ms]

    checking what it is happening in detail, see headers and answer

    GEThttp://form1generator.com/favicon.ico
    [HTTP/1.1 404 Not Found 0ms]


    GET
    http://form1generator.com/favicon.ico
    Status
    404
    Not Found
    VersionHTTP/1.1
    Transferred315 B (315 B size)
    Referrer Policystrict-origin-when-cross-origin


    HTTP/1.1 404 Not Found
    Date: Wed, 26 Oct 2022 14:27:14 GMT
    Server: Apache
    Content-Length: 315
    Keep-Alive: timeout=5, max=98
    Connection: Keep-Alive
    Content-Type: text/html; charset=iso-8859-1
    GET /favicon.ico HTTP/1.1
    Host: form1generator.com
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:106.0) Gecko/20100101 Firefox/106.0
    Accept: image/avif,image/webp,*/*
    Accept-Language: en-US,en;q=0.5
    Accept-Encoding: gzip, deflate
    Connection: keep-alive
    Referer: http://form1generator.com/V8/wizard.php
    Cookie: PHPSESSID=1c1c3cc941cc7e741851e39e02a9beb2

    could it be that cookie not set correctly get this error
    Regards,


    Fernando Vivolo

    ... new things are coming ...

  9. #9
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleMac Export ModuleFirefly 3D Module
    tobydavis's Avatar
    Join Date
    Apr 2019
    Location
    United States
    Posts
    96
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Retrobolt View Post
    What site can I go to for free hosting so I can test out this php script?
    Thanks
    I would really recommend that you use paid web hosting. The saying "you get what you pay for" also applies when you pay nothing. These free hosting sites always have some kind of limit. I'm currently hosting my zaptospark.com domain with a host called EthernetServers for $2.95 a month and haven't had any problems so far. If you're still set on free hosting though I do know of 000webhost (who are owned by Hostinger) and Byet Internet Services (they were used for the PHP registration tutorial on Clickteam's Tutorial page). It looks like both of them support PHP on their free plans.

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export Module
    Retrobolt's Avatar
    Join Date
    Mar 2016
    Posts
    438
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Fixed!

    Thank you everyone.

    After adding the header, I could only get 1 of 4 values even though I was using 4 different get objects at the start of the frame. But regardless of the number of get objects it can only get 1 at a time. Doing them all at the start of the frame with "on get complete"; caused only 1 value to be recived and 1 or all my different fusion values to be set to the 1 get on complete.

    So I made a cycle to go through each value at a time, not moving on to the next till the last get value was complete.

    Noting this for future devs, it was simple, but a pain to figure out.

    Thanks to the both of you!

Similar Threads

  1. Can Active Object load image from external source in HTML5 runtime?
    By yuki0022 in forum HTML5 Export Module 2.5
    Replies: 11
    Last Post: 15th August 2020, 12:33 PM
  2. [Request] Runtime object for HTML5
    By jobromedia in forum HTML5 Export Module 2.5
    Replies: 2
    Last Post: 6th December 2016, 06:19 AM
  3. Can i use HTML5 object in windows runtime
    By ramyhakam in forum Fusion 2.5
    Replies: 3
    Last Post: 30th November 2015, 11:15 AM
  4. Problem with animation on slopes and HTML5 runtime, platform engine - Please help
    By faber in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 12th December 2013, 10:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •