本文整理汇总了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());
}