Belajar Tentang CURL PHP

| Selasa, 25 November 2014
yuk langsung belajar.. dipelajarin ya  :D
Quote:
<?php
// set data yang diinput atau bisa menggunakan form input dengan method post
$email = 'admin@schoolid.org';
$pass = 'passwordnya';
$cookie = 'null';
?>

Quote:
<?php
if(isset($_POST['email']) // jika mempost email
{
$ch = curl_init(); // memulai curl
curl_setopt($ch, CURLOPT_HEADER, null); // head
curl_setopt($ch, CURLOPT_NOBODY, null); // body
curl_setopt($ch, CURLOPT_URL, "https://www.facebook.com/login.php"); // target url yang ingin di curl
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // verifiksai ssl host
curl_setopt($ch, CURLOPT_COOKIE, $cookie); // cokiee
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // mendeteksi jenis sistem ente seperti browser dan lainnya
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // verifikasi ssl
if ($url) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); // req method yang ente gunain
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"email=$email&pass=$pass&login=Login"); // field yang dipost atau diinput
}
$result = curl_exec($ch); // ini adalah resultnya
if ($result) {
return $result; // return result
//echo $result; // kalo kita ingin menampilkan resultnya
} else {
return curl_error($ch); // return kalo curl error
}
curl_close($ch); // close curl
} // menutup isset
?>

Kalo Masih Bingung bisa tanya di komentar :D

1 komentar:

  1. yg kayak // req method yang ente gunain
    // mendeteksi jenis sistem ente seperti browser dan lainnya
    // verifikasi ssl
    dll itu di script nya diisi yg kayak disuruh itu apa dibiarin?

    BalasHapus

Next Prev
▲Top▲