ALHUDA SHORTHAND AND IT INSTITUTE
BEST WEB DESIGNING AND DEVELOPMENT INSTITUTE IN MULTAN
The best institute of web designing and development in Multan, best web designing institute in Multan, web designing institute in Multan, web development courses in Multan,
Alhuda Shorthand & I.T Institute Multan is providing professional training of WEB DESIGNING AND DEVELOPMENT.
Address:
Twitter PHP login
- __construct() – Connect to the MySQL database.
- checkUser() – Insert or update the user profile data based on the OAuth provider and ID. Returns the user’s account data as an array.
Site Settings and API Configuration (config.php)
config.php
file, The constant variables are defined for database settings and Twitter API configuration.Database Constants:
- DB_HOST – Specify the database host.
- DB_USERNAME – Specify the database username.
- DB_PASSWORD – Specify the database password.
- DB_NAME – Specify the database name.
- DB_USER_TBL – Specify the table name where the user’s account data will be stored.
- TW_CONSUMER_KEY – Specify the Twitter App ID.
- TW_CONSUMER_SECRET – Specify the Twitter App Secret.
- TW_REDIRECT_URL – Specify the Callback URL.
- The PHP OAuth library is used to connect with Twitter API and working with OAuth client.
Login & Get Twitter Account Data (index.php)
- Initially, the authentication URL is generated using getAuthorizeURL() method of TwitterOAuth class and Sign in with Twitter button is displayed on the web page.
- If the user authenticates with their Twitter account, the following happens:
- The profile information is achieve by the Twitter account using Twitter API.
- The account data is inserted into the database using checkUser() function of the User class.
- The user’s account information is stored in the SESSION.
- The Twitter profile details (First name, Last name, Username, Locale, Picture, and Profile link) is displayed on the webpage.
- Also, the latest tweets and tweet posting form will be displayed.
- Using the Tweet form, the logged-in user will be able to post Tweet from the website to their Twitter account.