How to save json info to an array every 3 hours with php? -
i have access api under link:
it gets me ticket id in such manner:
jsonpcallback({ "ticket": "gezdimzrhftdezrygvstemjngm2dmlkmngrrwgmznha4dimrnge4dazrtmvrtkmjxmuzsytkxlezeetsqjq3dinkbgrdtmmshjfbumqksgnldkm2pkffvitcg" })
the issue every 3 hours expires.
how make php script regenerate evey 3 hours , save ticket into:
$config = array( "ticket" => "gezdimzrhfrwgmzqgjswkzrngyytcoldmdnrswczrnmiytimjnmnswgztbha2dgylbgi4cyn2cjnbdiu2kivbuewsukzhtoskbirkuyu2eivlfur2wkrbfkwci" );
thanks!
you can following similar managing oauth access token refresh:
- whenever retrieve soap authentication ticket, calculate expiration time adding 3 hours (or less) current time.
- save expiration time along soap authentication ticket.
- before each subsequent request, compare current time expiration time. if current time past authentication ticket expiration time, retrieve soap authentication ticket , save new expiration time before making request.
- in case make request , receive error, try re-authenticate, new authentication ticket , make request again.
this approach has follow benefits:
- only retrieve new authentication ticket when think need it.
- automatic refresh in case ticket has expired or otherwise invalidated.
- no need run external process.
Comments
Post a Comment