Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- paging
- RxKotlin
- Animation
- android13
- Kotlin
- MotionLayout
- list
- 인앱결제
- databinding
- PagingLib
- node.js
- mvvm
- 테스트 자동화
- junit
- MediaSession
- php
- GCP
- Android
- Observable
- 동영상
- google play
- MediaPlayer
- Reactive
- SWIFTUI
- node
- Android 13
- rx
- Koin
- SwiftUI Tutorial
- mysql
Archives
- Today
- Total
봄날은 갔다. 이제 그 정신으로 공부하자
[PHP] cURL 본문
cURL이란?
cURL은 "Client URL Library"의 약자로, 웹 서버나 FTP 서버 등과 통신하기 위한 라이브러리입니다.
PHP cURL은 PHP 프로그래밍 언어에서 사용되는 내장 함수 중 하나로 cURL을 사용하면 PHP 코드에서
다른 서버로 HTTP 요청을 보내거나 파일을 다운로드하고 업로드하는 등의 작업을 수행할 수 있습니다.
cURL을 사용해 HTTPS POST 호출
private function sendPost($idx){
$url = "https://myPostUrl";
$headers = array(
"content-type: application/json",
"accept: */*"
);
//POST방식으로 보낼 JSON데이터 생성
$postData = array();
$postData["myIdx"] = $idx;
$pack = json_encode($postData);
// CURL 초기화
$ch = curl_init();
// 요청 결과를 문자열로 반환받기 설정
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// set URL
curl_setopt($ch, CURLOPT_URL, $url);
// set HEADER
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// HTTP POST
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
// set BODY
curl_setopt($ch, CURLOPT_POSTFIELDS, $pack);
// set timeout
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
// send
$res = curl_exec($ch);
if(curl_error($ch)){
curl_close($ch);
return false;
}
// CURL close
curl_close($ch);
return true;
}'학습' 카테고리의 다른 글
| JSON String 파싱하는 방법 (0) | 2025.11.24 |
|---|---|
| JpaRepository DB 조회 방법 (0) | 2025.11.17 |
| node.js로 웹서비스 만들기 (24. 서버 다운 문제 대응) (1) | 2023.08.28 |
| node.js로 웹서비스 만들기 (23. Compute Engine 일정 관리) (0) | 2023.08.27 |
| node.js로 웹서비스 만들기 (22. Compute Engine 재 시작시 서비스 자동 실행하기) (1) | 2023.08.25 |
Comments