, , Zend Framework , getHeaders Headers, .
,
$request->getHeaders()->addHeaders(array(
'cache-control' => 'no-cache',
'content-type' => 'application/json',
'client_secret' => 'asdfasdfasdfasdfasdf',
'client_id' => 'asdfasdfasdfasdfasdf',
'accept' => 'application/json',
'authorization' => 'Basic MTIzNDoxMjM0',
));
$headers = $request->getHeaders();
$headers->addHeaders(array(
'cache-control' => 'no-cache',
'content-type' => 'application/json',
'client_secret' => 'asdfasdfasdfasdfasdf',
'client_id' => 'asdfasdfasdfasdfasdf',
'accept' => 'application/json',
'authorization' => 'Basic MTIzNDoxMjM0',
));
$request->setHeaders($headers);
:
URI Post, ,
$request->setUri('https://my.api.address.com/apiendpointurl1234');
$request->setMethod(Request::METHOD_POST);
, , , , , Content-Length ,
$request->setContent(json_encode(array(
'student_id' => '123456',
'short_description' => 'this is short description',
'description' => 'this is detailed description of the question',
)));
, script
$request = new Request();
$client = new Client();
$request->setUri('https://my.api.address.com/apiendpointurl1234');
$request->setMethod(Request::METHOD_POST);
$client->setOptions(['strictredirects' => true]);
$request->setContent(json_encode(array(
'student_id' => '123456',
'short_description' => 'this is short description',
'description' => 'this is detailed description of the question',
)));
$headers = $request->getHeaders();
$headers->addHeaders(array(
'cache-control' => 'no-cache',
'content-type' => 'application/json',
'client_secret' => 'asdfasdfasdfasdfasdf',
'client_id' => 'asdfasdfasdfasdfasdf',
'accept' => 'application/json',
'authorization' => 'Basic MTIzNDoxMjM0',
));
$request->setHeaders($headers);