PHP Classes

File: testapi.html

Recommend this page to a friend!
  Classes of silvio   spf PHP API Class JSON Library   testapi.html   Download  
File: testapi.html
Role: Auxiliary data
Content type: text/plain
Description: Test page.
Class: spf PHP API Class JSON Library
Handle API calls with parameters passed as JSON
Author: By
Last change:
Date: 4 years ago
Size: 11,275 bytes
 

Contents

Class file image Download
<!DOCTYPE html> <html> <title>TestApi</title> <meta charset='UTF-8'></meta> <meta viewport='width=device-width, initial-scale=1.0'></meta> <meta author='SPF Team'></meta> <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js'></script> <body> <h2>Test spfApi class</h2> <p> This page is useful to generate some types of http request. Target page is "spfApiSample.php", a sample page that uses the "spfApi" class to manage the request and send the response. </p> <label for="targetUrl">Target url:</label> <input type="text" id="targetUrl" size="50" value="http://localhost/spfapi/spfApiSample.php"> <br> <br> <h3>Test 1: post data by ajax</h3> <button id='btnTest1'>Send</button> <script> $("#btnTest1").click(function(){ console.log("button pressed"); var targetUrl = $("#targetUrl").val(); console.log("targetUrl: " + targetUrl); var params = { SPF_API_CMD: "getTest", SPF_API_PARAMS: JSON.stringify({ param1: 55, param2: "p2" }), name: "Donald Duck", logo: JSON.stringify({ encoding: 'base64', VALUE: "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAABmJLR0QA/wD/AP+gvaeTAAAbRUlEQVR4nO3de3xcZZkH8N9zZpK0TaEtlIug0tIudEFBSAFb2mQmM7nMTMOCGCqIioKsy1YE8QKyrtGVRdxFURDktrqyyEJZRNokTTLJTCZtQWgXRXFloXgB1gJSytL0ksx5n/2j9WPtljZp5j3PuTzfv/m8z6/knN+cmTnzHkAppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSinlKZIOoCqvbl1d1ZHbZrzDML3DYT4UwEzDNJMcTGPm6Tv/K6oh4ikAwExbAd4BAES0mQ3eAPhVh/CaIXrNIX5h4+TXX1g/f/2o2D9KWaEFE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PCcdRu2dFkBAtA02z3bBZwHcDmAh/Pm3+yWA5QTc39mQ/y/pMGr//HgQqf3I9jceQ3FKGNBC2lkGJ8D7r3QNgF8CtIbBa104hd6G3hc8zqAmSAsgBM4uJKbvIGeBg9gCdngeGMcCmIPKfb24GcAGABuY+Ffk4tGRMj2ab8q/UaH1lRAtgBA7J586dLSa5zDoWIYznRjTwKgFmSkGdBARDgIAZrzpgN8EO1tBGGbCGwSz2TXYMLmM53+U7n9N+t+ilFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUqHwfxEVESWwEb+YAAAAAElFTkSuQmCC" }), } $.post(targetUrl, params, function(data, status){ console.log("Data: " + data + "\nStatus: " + status); }); }); </script> <h3>Test 2: post data and files by html form</h3> <form method="post" id="formTest2" action="http://localhost/spfapi/spfApiSample.php" enctype="multipart/form-data" id="myform"> <input type="file" id="file" name="myFile1" /> <input type="hidden" name="SPF_API_CMD" value="getTestForm"> <input type="submit" id='btnTest2' value="Submit"> </form> <script> $("#btnTest2").click(function(e){ var targetUrl = $("#targetUrl").val(); console.log("button pressed 2"); console.log(e); e.preventDefault(); e.target.form.action = targetUrl; $("#formTest2").submit(); }); </script> </html>