How to save json info to an array every 3 hours with php? -


i have access api under link:

https://api.adform.com/services/security/login?username=api_user&password=mypassword&callback=jsonpcallback

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:

  1. whenever retrieve soap authentication ticket, calculate expiration time adding 3 hours (or less) current time.
  2. save expiration time along soap authentication ticket.
  3. 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.
  4. in case make request , receive error, try re-authenticate, new authentication ticket , make request again.

this approach has follow benefits:

  1. only retrieve new authentication ticket when think need it.
  2. automatic refresh in case ticket has expired or otherwise invalidated.
  3. no need run external process.

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -