Simple PHP application to create URL's like <ROOT_URL>/twitter_username
I am making a simple php application which uses twitter to login as shown in the example here at http://www.1stwebdesigner.com/tutorials/twitter-app-oauth-php/
However, instead of going to a page where the user posts a tweet, I want to redirect the user to a URL /twitter_user_name where he can see his twitter profile information. Also, this page needs to be publicly viewable at /twitter_user_name as the profile page of the person. I am not sure how I can create URL's like /twitter_user_name. I am not using any framework as such.My DB structure for the users table is:
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`oauth_uid` text,
`oauth_token` text,
`oauth_secret` text,
`is_logged_in` boolean开发者_高级运维,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
How do I accomplish this without using any framework?
Simple, use mod_rewrite
in a .htaccess
file:
RewriteEngine on
RewriteRule ^twitter_(.*)$ twitter_profile.php?username=$1 [L]
twitter_profile.php
will be called with GET
param (username) as $1
You can learn about mod_rewrite
and .htaccess
here.
精彩评论