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

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -