0

I want to connect with php to Mongo DB Api Endpoint. I know that there are drivers for PHP. But in my project it is not possible.

I have already created the endpoint in MongoDb. I got the following output:

curl --location --request POST 'https://eu-central-1.aws.data.mongodb-api.com/app/data-zymtt/endpoint/data/v1/action/findOne'
--header 'Content-Type: application/json'
--header 'Access-Control-Request-Headers: *'
--header 'api-key: xxxxx
--data-raw '{ "collection": "geocoordinatescol", "database": "geocoordinates", "dataSource": "cluster0", "projection": {"_id": "1} }'

I am new to curl in php. My question is how do I get this hooked up in PHP now. I have read in the docs of PHP that you can set the header but how do I get the data-raw submitted? Anahnd how can i save the returned JSON in an variable?

Would someone here have an example for me?

Translated with www.DeepL.com/Translator (free version)

i tried curl but without success.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345

0 Answers0