Hello anyone who will fall on this page :
Caching the login auth cookie, to avoid the error "The login request
used a username or password that is not recognized"

How can you do that ? (too bad the two ppl in the discussion did not
bother being more clear about that for all of us)


Here is an example code :

$storageZone="/var/www/storage";
$clientId="[email protected]";
$cacheLocation=$storageZone."/".str_replace("@","_",$clientId); //just
doing a str_replace to avoid @ in the filename

$usecache=false;

if(file_exists($cacheLocation)){
        $dMod=filemtime($cacheLocation);
        $secDiff=time()-$dMod;
        if($secDiff<60*5){ $usecache=true;}
}

if(!$usecache){
        $user = new AdWordsUser(NULL, $email, $password, $developerToken,
                                        $applicationToken, $userAgent, 
$clientId);
}else{
        $user=unserialize(file_get_contents($cacheLocation));
}
file_put_contents($cacheLocation,serialize($user));


the object $user can actually be serialized and stored for later
usage, i ve set the "caching" to 5 minutes, as i have no information
at all about the actual lifespan of the auth cookie.

Hope that will help some ! This works perfectly nice for me !

Pierre



On Apr 2, 4:33 pm, AdWords API Advisor <[email protected]>
wrote:
> Hi Dave,
>
> That's a great idea about the user submitted code snippets.  What do
> you think would be the best way to facilitate that?  Something simple
> we could do is create a wiki page like the one for PHP compatibility,
> where users can append comments.
>
>  http://code.google.com/p/google-api-adwords-php/wiki/PhpCompatibility
>
> Best,
> - Eric
>
> On Apr 1, 12:56 pm, Dave <[email protected]> wrote:
>
>
>
> > Caching the login auth cookie seems to have resolved my issue. The
> > examples provided in the library are great but I was taking it too
> > literally and authenticated before each query (2:00AM fail). Perhaps
> > myself or someone could contribute a full example from login ->
> > adgroup creation -> add keywords -> add ad -> etc.
>
> > The other example that people may be interested in is dynamically
> > setting the adwords client email/id:
> > // Sample Code
> > $user = new AdWordsUser();
>
> > // Set client account dynamically (Takes email or ID string)
> > // Instead of setting the client email statically in the auth.ini
> > $user->SetClientId("[email protected]");
>
> > It would be great if Google Adwords API or the PHP Client pages
> > allowed comments / user code snippets to be posted (example: php.net)
>
> > Thanks,
> > Dave
>
> > On Apr 1, 12:05 pm, "Joshua J. Kugler" <[email protected]> wrote:
>
> > > On Wednesday 31 March 2010, Dave elucidated thus:
>
> > > > I started using the aw_api_php_lib_2.0.1 client library w/ v2009 API
> > > > today and also ran into a rate limit. It produced the same error and
> > > > appears to only last for a few minutes. I don't use multiple threads
> > > > on my project but some of the operations are quick and I am
> > > > processing without any delay implemented.
>
> > > > I would be curious what the actual rate limit is, as bulk operations
> > > > aren't going to work well for my purpose. I don't mind adding a delay
> > > > I just don't want to guess if at all possible.
>
> > > Just so you know, you don't have to hit the Client Login API for each
> > > request. You can cache the auth cookie, and then only get a new one
> > > when you get back the error
>
> > > AuthenticationError.GOOGLE_ACCOUNT_COOKIE_INVALID
>
> > > If it is in fact a rate limit issue with the Login API, then caching the
> > > auth cookie should solve the problem.
>
> > > j
>
> > > --
> > > Joshua Kugler
> > > Part-Time System Admin/Programmerhttp://www.eeinternet.com
> > > PGP Key:http://pgp.mit.edu/ID0x73B13B6A

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Have you migrated to v200909 yet?
The v13 sunset is on April 22, 2010.

Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en

Reply via email to