mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-28 01:36:36 +00:00
added option for posting data in REST api
This commit is contained in:
parent
fddec32184
commit
b1482c512a
1 changed files with 7 additions and 4 deletions
|
@ -20,7 +20,7 @@ class Rest_Api {
|
||||||
* @param $host host for the website
|
* @param $host host for the website
|
||||||
* @return URL response.
|
* @return URL response.
|
||||||
*/
|
*/
|
||||||
public function request( $url , $applicationKey, $host )
|
public function request( $url , $applicationKey, $host , $data )
|
||||||
{
|
{
|
||||||
// Check the referer is the host website
|
// Check the referer is the host website
|
||||||
$referer = $_SERVER['HTTP_REFERER'];
|
$referer = $_SERVER['HTTP_REFERER'];
|
||||||
|
@ -36,10 +36,13 @@ class Rest_Api {
|
||||||
// Set the HTTP request authentication headers
|
// Set the HTTP request authentication headers
|
||||||
$headers = array(
|
$headers = array(
|
||||||
'AppKey: ' . $applicationKey,
|
'AppKey: ' . $applicationKey,
|
||||||
'Timestamp: ' . date( 'Ymd H:i:s', time() )
|
'Timestamp: ' . date( 'Ymd H:i:s', time() ),
|
||||||
|
'Accept: application/json',
|
||||||
|
'Content-Type: application/json'
|
||||||
);
|
);
|
||||||
curl_setopt( $session, CURLOPT_HTTPHEADER, $headers );
|
curl_setopt( $session, CURLOPT_HTTPHEADER, $headers );
|
||||||
|
curl_setopt( $session, CURLOPT_CUSTOMREQUEST, "POST" );
|
||||||
|
curl_setopt( $session, CURLOPT_POSTFIELDS, $data );
|
||||||
// Execute cURL on the session handle
|
// Execute cURL on the session handle
|
||||||
$response = curl_exec( $session );
|
$response = curl_exec( $session );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue