PHP | PHP에서 CURL을 사용하는 HTTP Post
페이지 정보
작성자 관리자 작성일18-01-12 16:30 조회1,139회 댓글0건관련링크
본문
//extract data from the post
extract($_POST);
//set POST variables
$url = 'http://www.yourdomain.com/data-post.php';
$fields = array(
'first_name' => urlencode($first_name),
'last_name' => urlencode($last_name),
'email' => urlencode($email),
'phone' => urlencode($phone)
);
//url-ify the data for the POST
foreach($fields as $key => $value) {
$fields_string .= $key.'='.$value.'&';
}
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields)); //CURLOPT_POST if set true, then you can POST the values.
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); //CURLOPT_POSTFIELDS will have all the values to be post on the $url.
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
extract($_POST);
//set POST variables
$url = 'http://www.yourdomain.com/data-post.php';
$fields = array(
'first_name' => urlencode($first_name),
'last_name' => urlencode($last_name),
'email' => urlencode($email),
'phone' => urlencode($phone)
);
//url-ify the data for the POST
foreach($fields as $key => $value) {
$fields_string .= $key.'='.$value.'&';
}
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields)); //CURLOPT_POST if set true, then you can POST the values.
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); //CURLOPT_POSTFIELDS will have all the values to be post on the $url.
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
[주소복사] https://www.goodsweb.kr/?u=D41KKA5b
SNS 알리기
핀터레스트
텔레그램로
블로그로
페이스북
트위터
카카오스토리
카톡 공유
관련 블로그
로딩중