lopes_andre Posted November 16, 2008 Share Posted November 16, 2008 Hi, I need to run a page using Curl. The page is like this: http://www.example.com/delete_a.asp?ID=571569 How can I send a command with Curl to run me this? Best Regards. Link to comment https://forums.phpfreaks.com/topic/132974-send-data-with-curl/ Share on other sites More sharing options...
ddrudik Posted November 16, 2008 Share Posted November 16, 2008 Do you need to POST data to this URL or do you just need to call the URL? To POST: $ch=curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.example.com/delete_a.asp?ID=571569"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,"somevar=".$somevar); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $someresultvar=curl_exec($ch); curl_close($ch); Link to comment https://forums.phpfreaks.com/topic/132974-send-data-with-curl/#findComment-691509 Share on other sites More sharing options...
redarrow Posted November 16, 2008 Share Posted November 16, 2008 If it helps <?php $url='http://www.example.com/delete_a.asp?ID=571569'; $get=file_get_contents($url); echo $get; ?> Link to comment https://forums.phpfreaks.com/topic/132974-send-data-with-curl/#findComment-691511 Share on other sites More sharing options...
lopes_andre Posted November 16, 2008 Author Share Posted November 16, 2008 Hi, Thaks for replys. It is not working. Let me explain... I have a function that works great but when we have an URL and DATA to post. Now I need to send only URL without data... function curl_login($url,$data,$proxy,$proxystatus){ $fp = fopen("cookie.txt", "w"); fclose($fp); $login = curl_init(); curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($login, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); curl_setopt($login, CURLOPT_TIMEOUT, 40); curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE); if ($proxystatus == 'on') { curl_setopt($login, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($login, CURLOPT_HTTPPROXYTUNNEL, TRUE); curl_setopt($login, CURLOPT_PROXY, $proxy); } curl_setopt($login, CURLOPT_URL, $url); curl_setopt($login, CURLOPT_HEADER, TRUE); curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($login, CURLOPT_POST, TRUE); curl_setopt($login, CURLOPT_POSTFIELDS, $data); ob_start(); // prevent any output return curl_exec ($login); // execute the curl command ob_end_clean(); // stop preventing output curl_close ($login); unset($login); } How can I modify this function to send only an URL with data, example: http://www.example.com/delete_a.asp?ID=571569 It is possible to modify the function? Best Regards. Link to comment https://forums.phpfreaks.com/topic/132974-send-data-with-curl/#findComment-691526 Share on other sites More sharing options...
lopes_andre Posted November 16, 2008 Author Share Posted November 16, 2008 Solved, with this function I can send URL and DATA in one time. function curl_login2($url,$proxy,$proxystatus){ $fp = fopen("cookie.txt", "w"); fclose($fp); $login = curl_init(); curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($login, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); curl_setopt($login, CURLOPT_TIMEOUT, 40); curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE); if ($proxystatus == 'on') { curl_setopt($login, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($login, CURLOPT_HTTPPROXYTUNNEL, TRUE); curl_setopt($login, CURLOPT_PROXY, $proxy); } curl_setopt($login, CURLOPT_URL, $url); curl_setopt($login, CURLOPT_HEADER, TRUE); curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($login, CURLOPT_POST, TRUE); ob_start(); // prevent any output return curl_exec ($login); // execute the curl command ob_end_clean(); // stop preventing output curl_close ($login); unset($login); } Regards, André. Link to comment https://forums.phpfreaks.com/topic/132974-send-data-with-curl/#findComment-691603 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.