ok so that was weird…
I just moved the $token = $keys->access_token ok one of the lines and its now working fine …
Strange thing is I tried teh modification locally and that caused errors but works without issues on domain …
Very odd …
Anyway resolved now many thanks for your help @BarryCarlyon