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()); }