Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. function postDataViaCurl($url,$parameters){
  2.         $ch = curl_init() or die("Sorry you need to have cURL extension Enabled");     
  3.         $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
  4.         $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
  5.         $header[] = "Cache-Control: max-age=0";
  6.         $header[] = "Connection: keep-alive";
  7.         $header[] = "Keep-Alive: 300";
  8.         $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
  9.         $header[] = "Accept-Language: en-us,en;q=0.5";
  10.         curl_setopt($ch, CURLOPT_URL, $url);
  11.         curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  12.         curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12");
  13.         curl_setopt($ch, CURLOPT_REFERER, $url);
  14.         curl_setopt($ch, CURLOPT_POST, 1 );
  15.         curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
  16.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  17.         $postResult = curl_exec($ch);
  18.         if (curl_errno($ch)) {
  19.             return false;
  20.         }
  21.         curl_close($ch);
  22.         return $postResult;
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement