From 750ded21bd66ed56e6baabe3f8cd88d5936732b9 Mon Sep 17 00:00:00 2001 From: shubham_meena Date: Thu, 14 Aug 2014 22:25:16 +0530 Subject: [PATCH] added option for posting data in REST api --HG-- branch : Gsoc14-ryzomAppImprovements --- .../server/ryzom_ams/ams_lib/autoload/rest_api.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/rest_api.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/rest_api.php index 91607292c..74281c6f6 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/rest_api.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/rest_api.php @@ -20,7 +20,7 @@ class Rest_Api { * @param $host host for the website * @return URL response. */ - public function request( $url , $applicationKey, $host ) + public function request( $url , $applicationKey, $host , $data ) { // Check the referer is the host website $referer = $_SERVER['HTTP_REFERER']; @@ -36,10 +36,13 @@ class Rest_Api { // Set the HTTP request authentication headers $headers = array( '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_CUSTOMREQUEST, "POST" ); + curl_setopt( $session, CURLOPT_POSTFIELDS, $data ); // Execute cURL on the session handle $response = curl_exec( $session ); @@ -66,4 +69,4 @@ class Rest_Api { return null; } } - } + }