I want to start a new website and chose wordpress as my cmd, but im having a restriction. The website is all about api request to other websites and i triedto get an api to test it as an example. After writing in php and add it to code snippet i got an error. I went through wordpress developers documentation and found out how to make an external api request, i did the same in the code snippet but still didn't work. So decided to code a php file and upload it into the wordpress directory, but before doing this, o decided to ask for help. About how to make and external api request from a wordpress website, where and how to input the code and use the api on a page or post?
This is the api i tried to use for test:
'''
curl --location --request POST 'https://api.apyhub.com/data/convert/currency'
--header 'Content-Type: application/json'
--header 'apy-token: APT03xPn2ZVq7rFriUtRoamaY9Ucg1c7y17CPd60WtMW03'
--data-raw '{
"source":"eur",
"target":"inr"
}'
'''
And i also tried using postman and it worked.
Please help.
apy-tokenis meant to be a private key, you should probably request a new one from the provider.wp_safe_remote_post()which allows you to send POST data to a remote URL and retrieve a response from it.