api - php+curl to send a post request with fields -


Trying to send post request to the API, to get an image back.

Example url:

  https://providers.cloudsoftphone.com/lib/prettyqr/createQR.php?user=1003123&format=png&cloudid=asdasdasd& The above URL works well in the browser, if the API does not request / postes, then  

The result of my code is always Invalid input '.

Code:

  $ url = 'https: //providers.cloudsoftphone.com/lib/prettyqr/createQR.php'; $ U = RAND (); $ P = rand (); $ Fields = array ('user' = & gt; urlencode ($ u), 'pass' => urlencode ($ p), 'format' = & gt; urlencode ('jpg'), 'cloud' = & Gt; urlencode 'test')); $ Ch = curl_init (); Curl_setopt ($ CH, CURLOPT_URL, $ url); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, 1); Curl_setopt ($ CH, CURLOPT_POST, 1); Curl_setopt ($ CH, CURLOPT_POSTFIELDS, $ fields); Curl_setopt ($ CH, CURLOPT_SSL_VERIFYPEER, incorrect); $ Output = curl_xac ($ CH); Curl_close ($ ch); $ Echo output;   

One note: Is there a way to debug the request to see what is being sent?

The URL provided is not working for the POST request. Here is the resulting screenshot (I have tried to use)

Enter image details here

Although it is fully working with the GET method, you can continue to use the GET request method to generate QR code.

I believe that GET is not more secure than POST method but when requesting curl user, in your case URL address (user id, password) will not be known. Because curl will be sent from your web server and not from the client / user's browser.

Later you can only output that response image, which you received from the API.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -