我試圖張貼登錄憑據的apigility登錄API:Apigility - 無效的內容類型指定
$response = ClientStatic::post(
'http://www.example.com/api/login',
array('email' => '[email protected]','password' => 'test'),
array('Accept' => 'application/json')
);
這將返回錯誤:
Cannot honor Accept type specified
據我所知,application/json
有已被列入白名單中的配置:
任何想法?
我Apigility配置:
<?php
return array(
'controllers' => array(
'factories' => array(
'Api\\V1\\Rpc\\Login\\Controller' => 'Api\\V1\\Rpc\\Login\\LoginControllerFactory',
),
),
'router' => array(
'routes' => array(
'api.rpc.login' => array(
'type' => 'Segment',
'options' => array(
'route' => '/api/login',
'defaults' => array(
'controller' => 'Api\\V1\\Rpc\\Login\\Controller',
'action' => 'login',
),
),
),
),
),
'zf-versioning' => array(
'uri' => array(
0 => 'api.rpc.login',
),
),
'zf-rpc' => array(
'Api\\V1\\Rpc\\Login\\Controller' => array(
'service_name' => 'Login',
'http_methods' => array(
0 => 'POST',
1 => 'GET',
),
'route_name' => 'api.rpc.login',
),
),
'zf-content-negotiation' => array(
'controllers' => array(
'Api\\V1\\Rpc\\Login\\Controller' => 'Json',
),
'accept_whitelist' => array(
'Api\\V1\\Rpc\\Login\\Controller' => array(
0 => 'application/vnd.api.v1+json',
1 => 'application/json',
2 => 'application/*+json',
),
),
'content_type_whitelist' => array(
'Api\\V1\\Rpc\\Login\\Controller' => array(
0 => 'application/vnd.api.v1+json',
1 => 'application/json',
),
),
),
'zf-content-validation' => array(
'Api\\V1\\Rpc\\Login\\Controller' => array(
'input_filter' => 'Api\\V1\\Rpc\\Login\\Validator',
),
),
'input_filter_specs' => array(
'Api\\V1\\Rpc\\Login\\Validator' => array(
0 => array(
'required' => true,
'validators' => array(
0 => array(
'name' => 'Zend\\Validator\\EmailAddress',
'options' => array(
'useDomainCheck' => true,
),
),
),
'filters' => array(),
'name' => 'email',
'description' => 'Email address',
'error_message' => 'Email address error',
),
1 => array(
'required' => true,
'validators' => array(),
'filters' => array(),
'name' => 'password',
'description' => 'Password required',
'error_message' => 'Password error',
),
),
),
'zf-mvc-auth' => array(
'authorization' => array(
'Api\\V1\\Rpc\\Login\\Controller' => array(
'actions' => array(
'Login' => array(
'GET' => false,
'POST' => false,
'PUT' => false,
'PATCH' => false,
'DELETE' => false,
),
),
),
),
),
);
謝謝 - 我正在使用wysiwig管理員創建我的api。這是從那裏控制,還是我需要手動添加?謝謝 – HappyCoder