1
正如你所看到的,'cover'和'parking'索引都是數組。但是當我回復我的迴應時,我得到了這樣的東西。
'cover'和'parking'鍵在json響應中都沒有顯示值。 所以這是我的控制器:
public function getPageInfoAction($page)
{
$request = (new FacebookRequest(
$this->initAppAction(),
'GET',
"/{$page}"
))->execute();
$graphObject = $request->getGraphObject();
//dump($graphObject);
//die;
return $graphObject->asArray();
}
這是我config.yml文件
#fos_rest
fos_rest:
param_fetcher_listener: force
view:
view_response_listener: 'force'
formats:
xml: true
json: true
templating_formats:
html: true
format_listener:
rules:
- { path: ^/, priorities: [ html, json, xml ], fallback_format: ~, prefer_extension: true }
exception:
codes:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
'Doctrine\ORM\OptimisticLockException': HTTP_CONFLICT
messages:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': true
allowed_methods_listener: true
access_denied_listener:
json: true
body_listener: true
disable_csrf_role: ROLE_API
所以,我怎麼能返回正確的JSON響應?
請轉換您的截圖到純文本 –
後精確的輸出,而不是屏幕截圖 – Rahul