2012-06-08 10:46:10 +00:00
|
|
|
<?php
|
2012-10-15 10:57:58 +00:00
|
|
|
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
|
|
|
2012-06-08 10:46:10 +00:00
|
|
|
class Mijireh_RestJSON extends Mijireh_Rest {
|
|
|
|
|
|
|
|
public function post($url, $data, $headers=array()) {
|
|
|
|
return parent::post($url, json_encode($data), $headers);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function put($url, $data, $headers=array()) {
|
|
|
|
return parent::put($url, json_encode($data), $headers);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function prepRequest($opts, $url) {
|
|
|
|
$opts[CURLOPT_HTTPHEADER][] = 'Accept: application/json';
|
|
|
|
$opts[CURLOPT_HTTPHEADER][] = 'Content-Type: application/json';
|
|
|
|
return parent::prepRequest($opts, $url);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processBody($body) {
|
|
|
|
return json_decode($body, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|