(Created page with "GFX permits also to interact with other APIs and websites through ENetworkSocket. ENetworkSocket is an object that makes http requests with get and post data to the specified ...")
 
 
Line 1: Line 1:
GFX permits also to interact with other APIs and websites through ENetworkSocket.
+
GFX permits also to interact with other APIs and websites through '''ENetworkSocket''' that is an object that makes http requests with get and post data to the specified address.
ENetworkSocket is an object that makes http requests with get and post data to the specified address.
+
------------
 +
<syntaxhighlight lang="php">
 +
$s = new ENetworkSocket("http://localhost");
 +
$c = $s->get("index.php");
 +
</syntaxhighlight>
 +
This will set content of '''$c''' to the content of ''http://localhost/index.php'' performing a get request.
 +
------------
 +
<syntaxhighlight lang="php">
 +
$postdata = array(
 +
"name"    => "john",
 +
"surname" => "smith"
 +
)
 
 
$s = new ENetworkSocket("http://localhost");
+
$s = new ENetworkSocket("http://localhost");
$c = $s->get("index.php");
+
$c = $s->post("index.php", $postdata);
+
</syntaxhighlight>
This will set content of $c to the content of http://localhost/index.php performing a get request.
+
 
+
This will set content of $c to the content of ''http://localhost/index.php'' performing a post request and
$postdata = array(
+
sending '''$postdata''' as '''$_POST''' value.
"name"    => "john",
 
"surname" => "smith"
 
)
 
 
$s = new ENetworkSocket("http://localhost");
 
$c = $s->post("index.php", $postdata);
 
 
This will set content of $c to the content of http://localhost/index.php performing a post request and
 
sending $postdata as $_POST value.
 

Latest revision as of 09:55, 30 July 2015

GFX permits also to interact with other APIs and websites through ENetworkSocket that is an object that makes http requests with get and post data to the specified address.


$s = new ENetworkSocket("http://localhost");
$c = $s->get("index.php");

This will set content of $c to the content of http://localhost/index.php performing a get request.


$postdata = array(
			"name"    => "john",
			"surname" => "smith"
			)
	
$s = new ENetworkSocket("http://localhost");
$c = $s->post("index.php", $postdata);

This will set content of $c to the content of http://localhost/index.php performing a post request and sending $postdata as $_POST value.


This page was last edited on 30 July 2015, at 09:55. Content is available under Creative Commons License SA 4.0 unless otherwise noted.