Skip to content

Instantly share code, notes, and snippets.

@tareko
Last active May 19, 2016 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tareko/aaf2c14ce3b5893fceccf13daa866d08 to your computer and use it in GitHub Desktop.
Save tareko/aaf2c14ce3b5893fceccf13daa866d08 to your computer and use it in GitHub Desktop.
HTTPSocket for login against REST
<?php
$HttpSocket = new HttpSocket();
// Set data
$data = array(
'username' => 'username',
'password' => 'password'
);
// JSON encode data
$data = json_encode($data);
// Set request options
$request = array(
'header' => array(
'Connection-Type' => 'application/json'
)
);
$results = $HttpSocket->post('https://example.com/rest/user/login', $data, $request);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment