Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

WordPress.com Connect PHP Demo

This is a simple PHP example demonstrating how to implement WordPress.com Connect (OAuth2 authentication) in your application.

Prerequisites

Setup Instructions

  1. Clone this repository (if you haven't already):

    git clone https://github.com/Automattic/wpcom-connect-examples.git
    cd wpcom-connect-examples/php
  2. Register a new application at WordPress.com Developer Console:

    • Set the Redirect URL to: http://localhost:8000/connected.php
    • Note your Client ID and Client Secret.
  3. Configure your credentials:

    • Open config.php in this folder.
    • Replace the values for CLIENT_ID and CLIENT_SECRET with those from your app's settings.
    • Adjust LOGIN_URL and REDIRECT_URL if you use a different port or domain.
  4. Start the PHP built-in server:

    php -S localhost:8000
  5. Test the demo:

    • Open http://localhost:8000/index.php in your browser.
    • Click the "Connect using your WordPress.com account" button.
    • Authorize the app and you should see a "Connection successful!" message.

Notes

  • This demo is for educational purposes. In a real application, you should securely store the access token and handle errors appropriately.
  • If you change the port or domain, update LOGIN_URL and REDIRECT_URL in config.php and in your WordPress.com app settings.
  • For more details, see the official documentation.