POST data and redirect user by PHP CURL
This is my workable solution for post with curl:
$postdata = "email=".$username."&pass=".$password; $ch = curl_init();curl_setopt($ch, CURLOPT_VERBOSE, false);curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch,CURLOPT_POST, sizeof($postdata));curl_setopt($ch,CURLOPT_POSTFIELDS, $postdata);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec ($ch);curl_close ($ch);
There is an alternative solution if above doesnt works:
$ch = curl_init();curl_setopt($ch, CURLOPT_VERBOSE, false);curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec ($ch);curl_close ($ch);