What are the best practices for defining and using OAuth consumer key and secret in PHP when working with the Xing API?

When working with the Xing API in PHP, it is important to securely define and use OAuth consumer key and secret to authenticate your application. To achieve this, you should store these sensitive credentials in a secure location, such as environment variables or a configuration file, and avoid hardcoding them in your code.

// Define and use OAuth consumer key and secret
$consumerKey = getenv('XING_CONSUMER_KEY');
$consumerSecret = getenv('XING_CONSUMER_SECRET');

// Check if consumer key and secret are defined
if (!$consumerKey || !$consumerSecret) {
    die('OAuth consumer key and secret not found.');
}

// Use consumer key and secret in your OAuth authentication process
// Example: 
// $oauth = new OAuth($consumerKey, $consumerSecret);