本文整理匯總了PHP中DfpUser::LogDefault方法的典型用法代碼示例。如果您正苦於以下問題:PHP DfpUser::LogDefault方法的具體用法?PHP DfpUser::LogDefault怎麽用?PHP DfpUser::LogDefault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DfpUser
的用法示例。
在下文中一共展示了DfpUser::LogDefault方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: RunExample
define('NETWORK_CODE', 'INSERT_NETWORK_CODE_HERE');
define('APPLICATION_NAME', 'INSERT_APPLICATION_NAME_HERE');
/**
* Run an example using the $user object.
* @param string $user the user that contains the client ID and secret
*/
function RunExample(DfpUser $user)
{
// Get the NetworkService.
$networkService = $user->GetService('NetworkService');
// Gets the current network.
$network = $networkService->getCurrentNetwork();
printf("Current network has network code %d and display name \"%s\".\n", $network->networkCode, $network->displayName);
}
// Don't run the example if the file is being included.
if (__FILE__ != realpath($_SERVER['PHP_SELF'])) {
return;
}
try {
$oauth2Info = array('client_id' => CLIENT_ID, 'client_secret' => CLIENT_SECRET, 'refresh_token' => REFRESH_TOKEN);
$user = new DfpUser(null, APPLICATION_NAME, NETWORK_CODE, null, $oauth2Info);
$user->LogDefault();
// Get the OAuth2 credential.
RunExample($user);
} catch (OAuth2Exception $e) {
ExampleUtils::CheckForOAuth2Errors($e);
} catch (ValidationException $e) {
ExampleUtils::CheckForOAuth2Errors($e);
} catch (Exception $e) {
printf("An error has occurred: %s\n", $e->getMessage());
}