Category : curl

in laravel 7 in one of my jobs I send a http request and for 95 percent of them I get html response. Request $url = "some url"; /** * Request with Guzzle and xml */ $response = Http::retry(3, 1000)->timeout(60)->withHeaders([ ‘User-Agent’ => ‘curl/7.65.3’, ‘Accept’ => ‘text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8’, ‘Accept-Encoding’ => ‘gzip, deflate, br’, ])->withOptions([ ‘referer’ => true, ..

Read more

i want to check respond code with this code <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ‘http://www.example.com/’); curl_getinfo($ch, CURLINFO_HTTP_CODE); $results = curl_exec($ch); curl_close ($ch); print_r($results); ?> but why, when i check result from print_r it show html code like this <!doctype html> <html> <head> <title>Example Domain</title> <meta charset="utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta name="viewport" ..

Read more

When I run this command in Mac terminal it give proper responce and output. curl -d "Authkey=rKgNwKnredMRx6RwVBH&Mask=Tyro&To=03217566679&Message=Hi this is test message" -H "Content-Type: application/x-www-form-urlencoded" -X POST https://sms.ahtess.pk/api/v1/quicksms.php I want to convert this in php curl_init command. I want to know how can I acheive this. The client give me this screenshot I tried to run ..

Read more

I built a php curl function for post and get requests: function startCurl($apiUrl, $requestType, $parameter) { if ($requestType == "POST") { $curl = curl_init(‘https://MY_IP/webapi/’.$apiUrl); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($parameter)); } else { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, ‘https://MY_IP/webapi/’.$apiUrl.’?’.http_build_query($parameter)); } #Some more code …. } At this part I check wich requestType (POST or GET) should use the ..

Read more

I give an example. I have a website called yyy.com and I post with curl from here. The website I posted on is xxx.com/post_al.php. After throwing the post with curl, I want my link in the browser to remain at xxx.com/post_al.php. So I want to open the browser and post from yyy.com and continue my ..

Read more