php curl http post 예제
우리는 WENSTENT the WONG TON TON TO www.example.com:=````````````aster.com.``username=user1, password = passuser1, gender = 1
// Initialize a cURL handle $ch = curl_init(); // Set the URL to post to curl_setopt($ch, CURLOPT_URL, "http://www.example.com/tester.phtml"); // Enable POST method curl_setopt($ch, CURLOPT_POST, true); // Set the POST fields $data = array('username' => 'user1', 'password' => 'passuser1', 'gender' => 1); $post_fields = http_build_query($data); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); // Receive server response curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $server_output = curl_exec($ch); // Close the cURL handle curl_close($ch); // Process the response if ($server_output == "OK") { // Handle successful response } else { // Handle error }
//] //] //] //] //] // $ ch = curl_init (); // 게시 할 URL을 설정합니다 curl_setopt ($ ch, curlopt_url, "http://www.example.com/tester.phtml"); // 게시물을 활성화합니다 curl_setopt ($ ch, curlopt_post, true); // 게시물 필드를 설정합니다 $ data = array ( 'username'=> 'user1', 'password'=> 'passUser1', 'gender'=> 1); $ post_fields = http_build_query ($ data); curl_setopt ($ ch, curlopt_postfields, $ post_fields); // 서버 응답을받습니다 curl_setopt ($ ch, curlopt_returntransfer, true); $ server_output = curl_exec ($ ch); // 컬 핸들을 닫습니다 curl_close ($ ch); // 응답을 처리합니다 if ($ server_output == "OK") { // 성공적인 응답을 처리합니다 } 또 다른 { // 오류를 처리합니다 } 이 PHP 컬 예제는 HTTP Post 메소드를 사용하여 지정된 데이터를 원격 서버로 보냅니다. 서버의 응답은 $ server_output 변수에 저장됩니다. 그런 다음 응답을 그에 따라 처리하고 예상 결과 = OK와 일치하는지 확인하거나 오류를 처리 할 수 있습니다.
부인 성명: 제공된 모든 리소스는 부분적으로 인터넷에서 가져온 것입니다. 귀하의 저작권이나 기타 권리 및 이익이 침해된 경우 자세한 이유를 설명하고 저작권 또는 권리 및 이익에 대한 증거를 제공한 후 이메일([email protected])로 보내주십시오. 최대한 빨리 처리해 드리겠습니다.
Copyright© 2022 湘ICP备2022001581号-3