User Tag List

Results 1 to 7 of 7

Thread: GET Object Tutorial Help

  1. #1
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jan 2018
    Location
    North Carolina, USA
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    GET Object Tutorial Help

    This is probably a silly question as I'm sure there's a ton out there but I'm not able to find a tutorial on using the GET Object. Could someone point me to a good...video or text.

    I'm attempting to send some data to a PHP script sitting on my web server and wait for the response from the page. However, I can't find anything on the GET Object, and the search term "Clickteam Fusion Get Object" pulls up everything BUT the GET Object. The only tutorial I saw was on YouTube...and it was in Russian (I speak English).

    Any help would be appreciated.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,366
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    The Get object is really simple. It can send and retrieve data. You can send Get Data in the url like this: http://www.myserver.com/mypage.php?n...ha&score=10000. You can also send Post Data using the Add Post Data action.

    I don't speak PHP (I'm a .Net guy), so I don't know exactly what you must do to retrieve the Get and Post calls on your server, but it seems it involves using $_POST and $_GET. Google it!
    Basically you create code that collects the data and use it the way you want.

    To call your server from Fusion, add Post data and THEN get the url. The order is important.
    To retrieve the data, create a new event and add the On Get Complete condition. You may display the data using a string, edit object or similar and setting it to Received$( "Get Object" ).

  3. #3
    Clicker Fusion 2.5 (Steam)

    Join Date
    Oct 2017
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont know much about the GET object but here is some Python script that can POST data to a PHP server.

    Code:
    import socket
    
    # Create a TCP/IP socket
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    
    # Get data to send
    temperature = input("Enter Temp: ")
    
    # Connect the socket to the port where the server is listening
    ip = socket.gethostbyname('iot.mitchelectronics.co.uk')
    server_address = (ip, 80)
    print('connecting to {} por {}'.format(*server_address))
    
    try:
        sock.connect(server_address)
    except Exception as e: 
        print("something's wrong with %s:%d. Exception is %s" % (address, port, e))
    finally:   
        dataToSend = "temperature=" + str(temperature) + "&var=20"
        POSTDATA = "POST /submit.php HTTP/1.1\r\n" + "Host: iot.mitchelectronics.co.uk\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: " + str(len(dataToSend)) + "\r\n" + "\r\n" + dataToSend
        sock.send(POSTDATA.encode())
        sock.close()
        print(POSTDATA)
    Here is some info on GET and POST

    https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
    https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html


    I imagine that with the GET object, you simply sent a GET request to a HTTP website (MUST contain HTTP://) and the website returns some data which you can get once the GET is done (see the attached simple example). POST data is interesting, you send a variable name and then you assign a value to that name (see the python code about).

    POSTDATA = "POST /submit.php HTTP/1.1\r\n" + "Host: iot.mitchelectronics.co.uk\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: " + str(len(dataToSend)) + "\r\n" + "\r\n" + dataToSend
    Attached files Attached files

  4. #4
    Clicker Fusion 2.5 (Steam)

    Join Date
    Oct 2017
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?php
    $Temp = "Test";
    $Temp=$_POST["temperature"];
    $Write="<h1>" . $Temp . "</h1>";
    file_put_contents('temp.html',$Write);
    ?>

  5. #5
    Clicker Fusion 2.5 (Steam)

    Join Date
    Oct 2017
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Figured it out


    GET Url action does BOTH Get and POST.

    To send data to a PHP script...

    Start of frame >
    Add POST Data (Variable Name, Variable Value as string)
    GET URL

    That will POST data to PHP script

    Edit - I cant believe I missed @Popcorn post

  6. #6
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jan 2018
    Location
    North Carolina, USA
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Popcorn View Post
    The Get object is really simple. It can send and retrieve data. You can send Get Data in the url like this: http://www.myserver.com/mypage.php?n...ha&score=10000. You can also send Post Data using the Add Post Data action.

    I don't speak PHP (I'm a .Net guy), so I don't know exactly what you must do to retrieve the Get and Post calls on your server, but it seems it involves using $_POST and $_GET. Google it!
    Basically you create code that collects the data and use it the way you want.

    To call your server from Fusion, add Post data and THEN get the url. The order is important.
    To retrieve the data, create a new event and add the On Get Complete condition. You may display the data using a string, edit object or similar and setting it to Received$( "Get Object" ).
    That was absolutely what I needed to know! I'm a PHP developer myself so doing the PHP is no issue at all, but I had no clue how to get started with the GET Object and trying to google that has turned out to be frustrating to say the least!

    Thank you so much, this will help me significantly!

  7. #7
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jan 2018
    Location
    North Carolina, USA
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by RobinMitchell View Post
    I dont know much about the GET object but here is some Python script that can POST data to a PHP server.

    Code:
    import socket
    
    # Create a TCP/IP socket
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    
    # Get data to send
    temperature = input("Enter Temp: ")
    
    # Connect the socket to the port where the server is listening
    ip = socket.gethostbyname('iot.mitchelectronics.co.uk')
    server_address = (ip, 80)
    print('connecting to {} por {}'.format(*server_address))
    
    try:
        sock.connect(server_address)
    except Exception as e: 
        print("something's wrong with %s:%d. Exception is %s" % (address, port, e))
    finally:   
        dataToSend = "temperature=" + str(temperature) + "&var=20"
        POSTDATA = "POST /submit.php HTTP/1.1\r\n" + "Host: iot.mitchelectronics.co.uk\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: " + str(len(dataToSend)) + "\r\n" + "\r\n" + dataToSend
        sock.send(POSTDATA.encode())
        sock.close()
        print(POSTDATA)
    Here is some info on GET and POST

    https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
    https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html


    I imagine that with the GET object, you simply sent a GET request to a HTTP website (MUST contain HTTP://) and the website returns some data which you can get once the GET is done (see the attached simple example). POST data is interesting, you send a variable name and then you assign a value to that name (see the python code about).

    POSTDATA = "POST /submit.php HTTP/1.1\r\n" + "Host: iot.mitchelectronics.co.uk\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: " + str(len(dataToSend)) + "\r\n" + "\r\n" + dataToSend
    I wanted to thank you as well! This was a great example and definitely is appreciated!

Similar Threads

  1. Doom tutorial - raycasting object - shooting zombies or gansters - tutorial
    By Sparckman in forum Guides, Tutorials, Examples, Widgets
    Replies: 0
    Last Post: 8th November 2015, 11:49 PM
  2. list object tutorial?
    By blurymind in forum Fusion 2.5
    Replies: 3
    Last Post: 2nd August 2014, 11:37 AM
  3. FTP Object tutorial?
    By ogrgkyle in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 21st August 2013, 03:45 AM
  4. Tutorial Update - INI object
    By Jeff in forum News
    Replies: 0
    Last Post: 30th November 2006, 01:59 AM

Posting Permissions

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