I’m creating a Symfony project that outputs JSON for consumption by an iPhone App.
I have a route set up:
notification_json:
url: /notifications.json
param: { module: notification, action: index, sf_format: json }
This currently lists all notifications (one of my models).
What I’d like to do is add some parameters to this, much like the Twitter API has ‘since_id’ – so if /notifications.json?since_id=3 was requested, only notifications with an ID higher than 3 would be shown.
I can’t see me struggling with the action logic, but the routing for this kind of thing has me scratching my head a little!
Any help would be extremely appreciated.
If you don’t specify any named parameters (eg
:myparam) when defining a route in yourrouting.yml, then any parameters you add on when generating the route will be appended as normal GET variables. For example:used with:
will give you:
If you add in named parameters into your route, then these will be substituted as normal, with any additional parameters tagged on the end as above, eg:
used with:
will give you: