开发者

Instagram style unique URLs

I am developing a CakePHP application which allows for photo uploads. It would be really nice if i could give the user a friendly unique URL of something like instagram does, ie:

http://example.com/v/157fd to view their single photo post.

What is the best approach for this, i take it its going to involve CakePHP routing at some point, but has someone got an flow of what would happen when a URL like this is hit and how these unique UR开发者_如何学JAVALs are formed?

Thanks


the route would be easy with one line (change the controller and action to yours):

Router::connect('/v/*', array('controller' => 'photos', 'action' => 'view'));

You can just use the photo id, or create your own random id. There's also a convenient way in cake to have random id, which is to use UUID

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜