-4

I want to convert command line cURL to PHP cURL in order to have better control.

Note it is included authentication with MYUSER and MYTOKEN.

Linux server is running Apache 2 and PHP 7.2.

curl -u 'MYUSER:MYTOKEN' 'https://example.com' -X POST --data '{"domainNames":["example.org","site2.com"]}'

What PHP code would you use to obtain the same functionality?

marya
  • 149
  • 2
  • 3
  • 11

1 Answers1

0

I haven't used PHP cURL, but I have done stuff using PHP exec. WARNING this is not completely recommended. But here is what I think you can be able to do:

<?php
   echo exec('curl -u \'MYUSER:MYTOKEN\' \'https://example.com\' -X POST --data \'{"domainNames":["example.org","site2.com"]}\'');
?>

More advanced examples can be found here: http://php.net/manual/en/function.exec.php

Along with this which is what you might actually be looking for: http://php.net/manual/en/book.curl.php

Riz-waan
  • 603
  • 3
  • 13