php 通過curl進行GET/POST(包含鑑權)請求

GET

$ch = curl_init();
$url = "https://apps.emaillistverify.com/api/verifyEmail?secret=".$key."&email=".$email;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
$result = curl_exec($ch);

POST

$url = "https://api.voilanorbert.com/2016-01-04/search/name";
$auth = 'user:b098-d3ee-4x16-99cd-3dbb';
$post_data = array('domain' => $domain,
                    'name' => $name);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
curl_setopt($ch, CURLOPT_USERPWD, $auth);  
$result = curl_exec($ch);


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章