Send and receive data
Sending and receiving data using the GET and POST methods are easy when using the SMRequest class.
$data = new SMKeyValueCollection(); $data["name"] = "Casper Jacksson"; $data["age"] = "29";
$postResponse = SMRequest::Post("http://domain.com/test.php", $data);
$getResponse = SMRequest::Get("http://domain.com/test.php", $data); |
The SMRedirect class can be used to perform redirects, allowing a request to be transfered to another URL.
header("location: http://google.com");
SMRedirect::Redirect("http://google.com"); |
In case redirecting is needed, use the Sitemagic solution. The Redirect function will make sure all data is properly committed, before redirecting the user to the specified address.
SMRequest class
| Function |
Return type |
Description |
| ::Post($url:string) |
String |
Perform Post request to specified URL - no data is transfered. Response is returned. |
| ::Post($url:string, $data:SMKeyValueCollection) |
String |
Post the supplied data to the specified URL. The response is returned. |
| ::Get($url:string) |
String |
Perform Get request to specified URL - no data is transfered. Response is returned. |
| ::Get($url:string, $data:SMKeyValueCollection) |
String |
Perform Get request with the data supplied to the specified URL. Response is returned. |
SMRedirect class
| Function |
Return type |
Description |
| ::Redirect($url:string) |
|
Re-locate user to specified URL. All data transactions are committed before redirecting.
|