I have the following command line script right now:
df -h | curl -F stuff=test http://foo.com
Which will send an POST Request to foo.com. In the $_POST variable I have the following data set:
[stuff] => test
Now I want to change test with the output from df -h so I can see it in my $_POST variable.
How can I do this?
You can use xargs
df -h | xargs -I % curl -F stuff=% http://foo.com
What have you tried? This might accomplish the goal. Try it out and let me know.
curl -F "stuff=`df -h`" http://foo.com
Related
I want to call my upload csv api using curl command but no able to upload file on that which gives me error.
Command I am using as follow:
curl -i -X POST -H "Content-Type:application/json" https://api.staging.mailzap.com/api/v1/api-key/upload-csv -d '{"apiKey":"Srkk8RL8xETAeJ0lTm85","email_csv":'#\"C:/Users/viral.champanery/Desktop/publicapi/test.txt\"',"team_id":282}'
following option also not working
curl -i -X POST -H "Content-Type:multipart/form-data;application/json;application/csv;" https://api.staging.mailzap.com/api/v1/api-key/upload-csv -d '{"apiKey":"Srkk8RL8xETAeJ0lTm85","email_csv":"C:/Users/viral.champanery/Desktop/publicapi/test.txt","team_id":282}'
also not working following
curl -i -X POST -H "Content-Type:multipart/form-data;application/json;application/csv;" https://api.staging.mailzap.com/api/v1/api-key/upload-csv -d '{"apiKey":"Srkk8RL8xETAeJ0lTm85","team_id":282}' -F "email_csv=#/C/Users/viral.champanery/Desktop/publicapi/test.csv"
email_csv=#/C/Users/viral.champanery/Desktop/publicapi/test.csv"
help me to upload file with json other parameter in api using curl command
curl -H 'Authorization: Token token=<your_private_token>' -X POST
-F job[webapp_id]=2
-F job[param]=""
-F files[0]=#test.txt
-F files[1]=#test2.csv
-F job[file_url]="http://www.lirmm.fr/DEMAR/images/inria_corpo_rvb.jpg"
-F job[dataset]=<my_dataset_name> https://allgo.inria.fr/api/v1/jobs
I want to convert this into PHP cURL format. I have tried out something but it isn't working properly. Really would appreciate any help!
So im trying to execute a terminal cURL command within a PHP script
The command in question
curl -H "public-api-token: mykeyhere" -X PUT -d "urlToShorten=google.com" https://api.shorte.st/v1/data/url
The response is a JSON and is as follows
{"status":"ok","shortenedUrl":"http:\/\/sh.st\/XXXX"}
I put it in my PHP script as follows, hoping it would add to a smaller and more effective code footprint
$cmd='curl -H "public-api-token: mysecretkey" -X PUT -d "urlToShorten=google.com" https://api.shorte.st/v1/data/url';
exec($cmd,$result);
print_r($result);
However the returned array is empty
The result is
Array ( )
exec() returns the last line of output, try using shell_exec().
Basically, this works:
ldapsearch -H ldap://test.domain.pri -x -b dc=domain,dc=pri -D test1 -W
This does not:
ldapsearch -H ldap://test.domain.pri -x -b dc=domain,dc=pri -D test.2 -W
The existence of a dot in the username seems to be the only determining factor here.
Any suggestions?
Try quoting the value for -D:
ldapsearch -H ldap://test.domain.pri -x -b dc=domain,dc=pri -D "test.2" -W
My other thought: the -D param is supposed to provide the distinguished name (DN). Is "test.2" really a valid DN in your setup?
Thanks for the suggestions! It turns out however that the client has something in place which replaces periods with spaces in the username. So the problem was not on my end!
For those who may still encounter this issue. Try using full UPN after -D. I found it to work with periods flawlessly:
ldapsearch -H ldap://test.domain.pri -x -b dc=domain,dc=pri -D "test.2#domain.pri" -W
I can't seem to find any reference to the LH command this cURL command uses -- so I'm not entirely certain how to translate it to php
$ curl -LH "Accept: text/bibliography; style=mla; locale=fr-FR" http://dx.doi.org/10.1038/nrd842
curl -LH is just two flags L and H.
See: http://curl.haxx.se/docs/manpage.html
-L = Location
-H = Header
In your code, you should either swap your flags to -HL or swap your argument values.