API permission issues using php file_get_content

[Help]
h**p://localhost/httpdocs/api/?action=view&object=tb_penduduk&key=1119062803910001

i am trying using phpmaker api. When i paste the link above in address bar, it works smoothly like a charm.
But when i wrap it in php functions file_get_contents, it will return error message like this:
array(3) { [“success”]=> bool(false) [“failureMessage”]=> string(65) “You do not have permission to access /httpdocs/api/index.php.” [“version”]=> string(7) “16.0.14” }

what is the proper way to do this?
Any help would be highly aprreciated. Thanks in advance.

If you use API, you need to pass the JWT token with the context argument, see https://www.php.net/manual/en/function.file-get-contents.php.

Thanks for your response.
In this case, I left all options related to JWT unticked in Advanced Settings menu. And I always use this API service for localhost usage only.
Anyway, I’ll try to learn your advice. Many thanks,
Regards

You still need to send JWT token.