/// <summary> /// This example verifies an association session callback token. /// </summary> /// <param name="adsense">AdSensehost service object on which to run the requests.</param> /// <param name="callbackToken">The token returned from the association callback.</param> public static void VerifyAssociationSession(AdSenseHostService adsense, string callbackToken) { Console.WriteLine("================================================================="); Console.WriteLine("Verifying new association session"); Console.WriteLine("================================================================="); // Verify the association session token. AssociationSession associationSession = adsense.Associationsessions.Verify(callbackToken) .Execute(); Console.WriteLine("Association for account {0} has status {1} and ID {2}.", associationSession.AccountId, associationSession.Status, associationSession.Id); Console.WriteLine(); }
/// <summary>This example starts an association session.</summary> /// <param name="adsense">AdSensehost service object on which to run the requests.</param> /// <param name="websiteUrl">The URL of the user's hosted website.</param> /// <returns>The created association.</returns> public static AssociationSession StartAssociationSession(AdSenseHostService adsense, string websiteUrl) { Console.WriteLine("================================================================="); Console.WriteLine("Creating new association session"); Console.WriteLine("================================================================="); // Request a new association session. AssociationSession associationSession = adsense.Associationsessions.Start( AssociationsessionsResource.StartRequest.ProductCodeEnum.AFC, websiteUrl).Execute(); Console.WriteLine("Association with ID {0} and redirect URL \n{1}\n was started.", associationSession.Id, associationSession.RedirectUrl); Console.WriteLine(); // Return the Association Session that was just created. return(associationSession); }