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: The result of my code is always Invalid input '. Code: One note: Is there a way to debug the request to see what is being sent? The URL provided is not working for the Although it is fully working with the 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 Later you can only output that response image, which you received from the API.
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
$ 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;
POST request. Here is the resulting screenshot (I have tried to use)
GET method, you can continue to use the GET request method to generate QR code.
curl will be sent from your web server and not from the client / user's browser.
Comments
Post a Comment