I'm working on integration with sentione api. I have problem with guzzle, guzzle throws me 401 Unauthorized exception. I think it can be problem with post data, I tried to set it in another way, but I'm getting always the same result.
That's my code:
$arr = array(
'topicId' => id,
'from' => '2014-01-01 00:00:00.000 CET'
);
$params = json_encode($arr);
$client = new Client('http://sentione.com/api', array(
'request.options' => array(
'headers' => array(
"Accept: application/json",
"X-API-KEY: key",
"Content-type: application/json",
)
)
));
$request = $client->post('statements/search', array('Content-Type' => 'application/json'), $params);
$response = $request->send();
And that's my cURL definition:
$arr = array(
"topicId" => id,
"from" => "2014-01-01 00:00:00.000 CET"
);
$json = json_encode($arr);
$headers = array(
"Accept: application/json",
"X-API-KEY: key",
"Content-type: application/json",
);
$url = "http://sentione.com/api/statements/search";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
$response = curl_exec($curl);
Of course it's working great. Anybody can help me? Maybe I forgot sth?