0

I want to pass parameters with cURL and get it using argv

Just like -

curl 'http://xx.xx.xx.xx/test.php {MY JSON DATA}'

and I want this json data as an argument - like it should print an array of arguments like

Array
(
    [0] => test.php
    [1] => 2345232wqwfdwfsdf
)

Note - I can use POST/PUT method for getting the data but I want to know can I use argv when using curl command?

martynas
  • 12,120
  • 3
  • 55
  • 60
Raj Sf
  • 1,408
  • 1
  • 17
  • 26

1 Answers1

1

As for the posting of the data, see How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?

As for reading it inside of php, it will be in $_POST

Community
  • 1
  • 1
Uberfuzzy
  • 8,253
  • 11
  • 42
  • 50
  • Yes I can use POST PUT method for this but I am just curious about use of argv with curl command :) – Raj Sf Apr 18 '14 at 07:27
  • 1
    Since curl is fetching a url, its going through a http server of some sort, which means your data will be passed either GET or POST data, not as argv data to the php executable or the php script. – Uberfuzzy Apr 18 '14 at 07:29
  • 1
    php (when run directly) does have support for argv, but its prefaced with the script being run. Check out http://www.php.net/manual/en/reserved.variables.argv.php – Uberfuzzy Apr 18 '14 at 07:30