Unable to update a form using curl post - php

I am trying to use a script to interact with the a website however whenever i send my curl post request, nothing is returned.
curl -X POST --proxy 1.1.1.1:9443 \
-H "Content-Type: application/x-www-form-urlencoded" -d d="google.com" -d n="8.8.8.8" \
-d q="A" http://http://www.kloth.net/services/dig.php

Related

Display Symfony's HTTP request as a cURL request

I am trying to troubleshoot a symfony's HTTP client request. How can one display the anticipated request as a cURL request such as the following? Thank you
curl -X 'PUT' \
'https://example.com/projects/01GPX8HPBQ54SA11JKWPWFESM6/document_acl' \
-H 'accept: application/ld+json' \
-H 'Authorization: Bearer blaBlaBla' \
-H 'Content-Type: application/ld+json' \
-d '{}'

Cloudflare API - Curl request to block IP with IP Access Rules

I manually block IP to access my site (dlandroid.com) with Cloudflare "IP Access Rules",
My question is how to block an IP with Cloudflare API Curl request using PHP?
I search API document and find this but don't know how to use it with PHP:
curl -X GET "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/access_rules/rules?page=1&per_page=20&mode=challenge&configuration.target=ip&configuration.value=198.51.100.4&notes=my note&match=all&order=mode&direction=desc" \
-H "X-Auth-Email: user#example.com" \
-H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
-H "Content-Type: application/json"
also check this: https://api.cloudflare.com/#firewall-access-rule-for-a-zone-list-access-rules

Not able to upload file using curl command with other json parameter in lumen php project api

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

Sending json file through Http Post curl

I have been working with Jenkins, and now Im stuck when I try to make an HTTP Post using curl, I am sending a json file, to a file in my page who is waiting for it, and then do some functions, the code I am using is the following:
curl -X POST -k -i -H "Accept: application/json" -w "%{body}" -w "%{http_code}" -d "#/var/lib/jenkins/workspace/myFolder/session.json" http://mypage.com/myFolder/newfile.php
But apparently Im not sending correctly the data of the file, the newfile.php has something like this:
echo $_REQUEST['sessionId'];
But always get an error when I try to echo the index sessionId, I mean my file "newfile.php" is not getting anything from my jenkins curl, can you help me out?
Thanks in advance!!
The JSON that you send is in the request body. The keys/values will not be available in the $_REQUEST array, hence why you are getting the error. You will need to access the request body in order to get the sessionId property.
$requestBody = file_get_contents('php://input');
$session = json_decode($requestBody);
$sesionId = $session["sessionId"];
echo "Session ID: $sessionId";
The file_get_contents('php://input') returns the body of the POST request.
Make sure to also add the appropriate Content-Type header to your post request:
curl -X POST -k -i -H "Accept: application/json" -H "Content-Type: application/json" -w "%{body}" -w "%{http_code}" -d "#/var/lib/jenkins/workspace/myFolder/session.json" http://mypage.com/myFolder/newfile.php`

How to write XPOST CURL request in php?

I want to know how write the follwong curl (cmd) command in php curl
annotations.xml is an xml file
curl -v -u admin:geoserver -XPOST -T annotations.xml -H "Content-type: text/xml"
http://localhost:8080/geoserver/rest/workspaces/acme/datastores/nyc/featuretypes

Categories