0

I have the following code:

$routes = array( 'twitter_output' => new Zend_Controller_Router_Route( 'twitter/:username\.:format', array('controller' => 'twitter', 'action' => 'index') ) ); 

Basically I want it to match: http://site.com/twitter/edu2004eu.json (except not only json, maybe xml and others too).

But when I print my request object, it gives me:

[_params:protected] => Array ( [username\.:format] => edu2004eu.json ) 

but it should say:

[_params:protected] => Array ( [username] => edu2004eu, [format] => json ) 

I don't know what I'm doing wrong here. Any help would be appreciated.

EDIT: I've tried the same with a slash instead of a dot (http://site.com/twitter/edu2004eu/json) and it seems to be working, but I want the dot (to be cool like all APIs)

1 Answer 1

1

I don't think the standard route type is set to use dot as a separator. You could use a regexp route instead:

$routes = array( 'twitter_output' => new Zend_Controller_Router_Route_Regex( 'twitter/([\w]+)\.([\w]+)', array('controller' => 'twitter', 'action' => 'index'), array(1 => 'username', 2 => 'format'), 'twitter/%s.%s' ) ); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.