Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example JHttp Use
// Set up our JRegistry object for the HTTP connector
$options = new JRegistry;
// Set the user agent
$options->set('userAgent', 'JInstallation/3.0');
// Use a 120 second timeout
$options->set('timeout', 120);
// Instantiate our JHttp object
$http = new JHttp($options);
// Build our data array
$data = array(
'data1' => 'foo',
'data2' => 'bar',
'data3' => 'Login'
);
// JSON encode the data
$data = json_encode($data);
// Post the data
$response = $http->post('http://localhost:8888/curl/get-data.php', $data);
// Check if we received the proper response code
if ($response->code != 201)
{
// Error condition
}
// From here, build the response object for the installer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.