Posts

Showing posts with the label curl

curl HTTPS via an SSH proxy

Image
Clash Royale CLAN TAG #URR8PPP curl HTTPS via an SSH proxy I want the below curl command to run from my machine, but via a remote proxy server. curl "https://site.fake/ping" However, I want this to always work via a remote proxy server. I was tring to set this up with an ssh tunnel: sudo ssh -i ~/.ssh/private_key_file -L 443:site.com:443 username@remote.proxy.com But this did not do the trick, running under osx. Any suggestions? 1 Answer 1 Try using a socks5 proxy for example: socks5 $ ssh -D 8080 -f -C -q -N user@remote.host Then you could use curl like this: curl curl -x socks5h://0:8080 https://example.com By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

c++ curl returns 413 request entity too large however the post size is much less than max size

Image
Clash Royale CLAN TAG #URR8PPP c++ curl returns 413 request entity too large however the post size is much less than max size I noticed that some of my posts weren't submitted so I saw the output from curl in the c++ code and it gave I tested the max size allowed for post requests on the php side with this : echo ini_get('post_max_size'); and I got : 20M then got the size of the post being sent from the c++ code like this : void send_request(string url, string field,string data) { string post_req = field + "=" + data; CURL *curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_req.c_str()); cout << "post size : " << post_req.size() << endl; curl_easy_perform(curl); curl_easy_cleanup(curl); } the post was only 1059544 bytes = 1M it's far from 20M where is the problem in php side ? or c++ code ? By c...

Basic JSON Decode foreach loop not working php

Image
Clash Royale CLAN TAG #URR8PPP Basic JSON Decode foreach loop not working php been going at this for quite some time and I'm puzzled as to why using foreach loops does not work but the other way I show does work. My Code: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://maps.googleapis.com/maps/api/geocode/json?address=1%20The%20Strand%20Wellard"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/json" )); $response = curl_exec($ch); $json = json_decode($response, true); foreach ($json['results'] as $item) { foreach ($item['geometry'] as $item2) { foreach ($item2['location'] as $item3) { echo $item3['lat']; } } echo $item['geometry']['location']['lat']; } curl_close($ch); JSON Data: https://pastebin.com/JU1wSpsD Why doesn't echo $item3['lat']; work but ech...

Execute multiple parallel cURL against the same URL?

Image
Clash Royale CLAN TAG #URR8PPP Execute multiple parallel cURL against the same URL? I need to execute 2 requests in parallel using cURL to get a reply from the web service. The problem is that I need to get the encrypted password from the first XML's output and pass it to the second XML to get 100 success response from the API. Currently, I have created 2 cURL to achieve this but the API responds "101 Password Expired" because the encrypted password is valid only for the first request. Here is my code for reference: 1st cURL: $soapUrl = "http://localhost:54934/frmMutualFund.asmx?op=getPassword"; // asmx URL of WSDL // xml post structure $xml_post_string = '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> ...

PHP CURL API token retrieval

Image
Clash Royale CLAN TAG #URR8PPP PHP CURL API token retrieval I've read everything on multiple boards and not succeeded...need the brains trust. what i'm getting: HTTP/1.1 400 Bad Request preload {"error":"unsupported_grant_type"} my goal: to retrieve the OAuth token from the FQDN/api/token endpoint i have: endpoint, username & password (no secret or key) i can curl from the shell and get the token - i just can't get php to do it >/ my code isn't mine anymore since i was pretty sure i was the problem but here is what i'm presently attempting to utilise: (can someone point out where i'm being a muppet!) $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://FQDN/api/token", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST...

PHP curl setopt httpheader not working

Image
Clash Royale CLAN TAG #URR8PPP PHP curl setopt httpheader not working I observed network status when loading public website and I try to curl the website. However, it turns out that the curl result will redirect me to an error page instead to the final page. In this case I try to modify the request headers especially host and referer but then it turned out that the headers are still pointing to localhost. Besides that, can I "maintain" the modified headers information during the other request processing works in the same page load? function curlFollow($url){ $handle = curl_init(); $host = parse_url($url,PHP_URL_HOST); // var_dump($url);exit(); $curlHeaders = array( "Host: $host", "Referer: $url", "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36", "Accept: application/json, text/plain, */*", "Accep...

How to convert a HttpServletRequest to a cURL command line?

How to convert a HttpServletRequest to a cURL command line? I want to convert a HttpServletRequest to a cURL command line for debugging. How to do this? 1 Answer 1 The most common information are: getRequestURL getHeaders getMethods You will find all information in documentation: https://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html https://curl.haxx.se/docs/manpage.html By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.