1

I know how to make curl from http to https but I can't do it from https to http server ?

here is my req address in nodejs without ssl http://printer-manager.cafe-viuna.com/abc/?clinet_id=999&printer_id=p1&url=https://viunaorder.avishost.com/pdf/18217.pdf

but I can't send it from a ssl page , thank you very much .

enter image description here

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://printer-manager.cafe-viuna.com/abc/?clinet_id=47&printer_id=p1&url=https://viunaorder.avishost.com/pdf/18217.pdf');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);


curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); // On dev server only!
$result = curl_exec($ch);
print_r($result);
dev moore
  • 75
  • 8
  • 4
    I don't understand what "from http to https" and "from https to http" would mean. Curl doesn't care whether it's being run on a secure web page, a command-line script, or a fridge - it just makes an HTTP request to wherever you tell it to. Perhaps you can [edit] the question to show some PHP code you've tried, and explain what happened when you ran it, and what you expected to happen instead? – IMSoP Jan 18 '22 at 14:21
  • Curl runs in the backend, on your server. It does not know or care whether the connection from browser to server to trigger the script it's within was secured by https or not. That's irrelevant. I'm going to guess you're misattributing some other problem to that cause, but you haven't told us what the actual problem is, so it's hard to suggest a cause or fix. – ADyson Jan 18 '22 at 14:22
  • I assume this is calling a piece of code that accepts a pdf filename as input and that pdf exists on the `viunaorder.avishost.com` website. So show us the code that is in `http://printer-manager.cafe-viuna.com/abc/` that is accepting the pdf and sending it to the printer – RiggsFolly Jan 18 '22 at 14:29
  • @IMSoP , hello could you pelase see my code adn errors , I think so Curl doesn't care whether it's being run on a secure web page , but when I print_r the other side is javascript and not a single page ? – dev moore Jan 19 '22 at 09:07
  • @ADyson , I put the code – dev moore Jan 19 '22 at 09:12
  • @RiggsFolly see the code please – dev moore Jan 19 '22 at 09:13
  • So you are just trying to dump the entire content of another page into yours? Can I ask why? It rarely ends well. – ADyson Jan 19 '22 at 09:14
  • So what seems to be actually happening here is nothing to do with curl. The content you're printing into your page from that other site is trying to make an AJAX request back to itself, but since your page is HTTPS, and it's trying to make an AJAX request to a HTTP URL, that's blocked as being insecure. I would suspect that even if you could fix that, it would then be blocked instead because of CORS. Again - not really sure why you're trying to dump someone else's page into your own? – ADyson Jan 19 '22 at 09:16
  • 1
    That screenshot is not the result of any PHP code, it's a browser error because of the _resulting HTML_. It might help you to refresh your understanding of [the difference between client-side and server-side processing](https://stackoverflow.com/q/13840429/157957). – IMSoP Jan 19 '22 at 09:16
  • @IMSoP Sure , I know the printer manager that I need to call is Node.js and I wnat to call it from php if I dont print_r the resulat the req will send ? – dev moore Jan 19 '22 at 09:17
  • 1
    @devmoore Node.js is **server-side** processing; the error you've shown is **client-side**. You've got yourself in a twist somewhere if you think that you're calling node.js from PHP this way. – IMSoP Jan 19 '22 at 09:19
  • how to I open req to node.js from PHP ? – dev moore Jan 19 '22 at 09:24
  • cURL makes HTTP requests. So if you want to send a request to any server (whether that server runs nodesJS, PHP, asp.net or whatever else doesn't matter to the caller - it's still a HTTP request at the end of the day), you can use cURL for that. – ADyson Jan 19 '22 at 09:27

0 Answers0