|
ConfigurationAndUse
Configuration and use of SensAPIlity IntroductionThis document will cover how to configure SensAPIlity's options and give a very brief overview of how to integrate it with other PHP code. In this document "$VER$" means whatever version of SensAPIlity you download. Download
ConfigureIn the google-sensapility-$VER$ directory there is a file named settings.ini. This file is where you can set what the state of the SensAPIlity library should be at startup. The options are pretty self-explanatory, but below is a brief description. It is recommended that you set the !adSenseAddress, !developerEmail, and !developerPassword parameters of this file. You can set these parameters at run time, but doing this is not well tested. SECRUITY WARNING: If you put your developerEmail and developerPassword in settings.ini, the settings.ini file should be placed in a non-web accessible location or your web server should be configured not to serve this file. adSenseAddress - the address that the AdSense API services are located at. It is important to note that this string should end with a forward slash. developerEmail - the email address corresponding to the AdSense API developer account you are using. developerPassword - the password corresponding to the AdSense API developer account you are using. search-client-id, content-client-id, and referral-client-id - the publisher ids of the client account. You can set and reset these at run time using SensapilityAuthentication.setPubIds() . For more information on this see ChangingCredentialsAtRuntime. UseUsing SensAPIlity is very easy. All you need to do is import sensapility.php and the rest takes care of itself. Assuming you place the google-sensapility-$VER$ directory in the same directory as your PHP program file, your import looks like this: require_once('google-sensapility-$VER$/sensapility.php'); When sensapility.php runs, it will place two objects in the global namespace. $SENSAPILITY_AUTH and $SENSAPILITY_CLIENTS. $SENSAPILITY_AUTH controls authentication aspects of the AdSense API. It is in charge of your developer credentials and the publisher id(s) that you are using. $SENAPILITY_CLIENTS is the object you access to get an object that will access an AdSense API service. Assuming that you have set at least one client id value in settings.ini, getting association status from the account service is as easy as this: <?php
require_once('google-sensapility-$VER$/sensapility.php');
global $SENSAPILITY_CLIENTS;
$accountService = $SENSAPILITY_CLIENTS->getService('Account');
$assocationStatus = $accountService->getAssociationStatus();
?>For more information on $SENSAPILITY_AUTH see ChangingCredentialsAtRuntime. |
Sign in to add a comment