如何将$ data发送到fetchOne apigility休息?

时间:2016-01-19 14:28:56

标签: php rest zend-framework2 apigility

如何向Rest Apigility发送[0][0][1][0] [1][0][0][0] [0][0][0][1] (某个值 - >数组)以进行查询并返回结果这是我的发送代码$data

$data

获取关于Apigility的$body = $this->getRequest()->getContent(); $json = json_decode($body, true); $conditions =array( 'artist' => $json['data'] ); $client = new Client(); $uri = "http://localhost:81/ApigilityNew/public/albums"; $user = 'admin'; $password = 'admin'; //url del servicio REST $client->setUri($uri); //establecer metodo GET-POST $client->setMethod('GET'); //tiempo de peticion $client->setOptions( [ 'maxredirects' => 0, 'timeout' => 60 ] ); $client->setHeaders(['Accept' => 'application/json', 'Contet-Type' => 'application/json']); $client->setAuth($user, $password , $client::AUTH_BASIC); $client->setParameterGet($conditions); $response = $client->send($client->getRequest());

AlbumResource.php

$data

AlbumMapper.php

   /**
     * Fetch a resource
     *
     * @param  array $condiciones
     * @return ApiProblem|mixed
     */
    public function fetch($conditions) //$id
    {
        //return new ApiProblem(405, 'The GET method has not been defined for individual resources');
        return $this->mapper->fetchOne($condiciones);
    }

如何获得结果?现在它只从Apigility

返回不支持的媒体类型

1 个答案:

答案 0 :(得分:1)

您的ContentType标题中有拼写错误:

'Contet-Type' => 'application/json'

应该是:

'Content-Type' => 'application/json'

这可能是您获得不支持的媒体类型消息的原因