"일꾼이 일을 잘하려면 먼저 도구를 갈고 닦아야 한다." - 공자, 『논어』.
첫 장 > 프로그램 작성 > 명령 줄 curl을 PHP 컬로 변환하는 방법은 무엇입니까?

명령 줄 curl을 PHP 컬로 변환하는 방법은 무엇입니까?

2025-02-06에 게시되었습니다
검색:541

How to Translate Command Line cURL to PHP cURL?

php curl 번역 :

php 에서이 명령을 복제하려면 다음 단계를 따를 수 있습니다. URL 및 Filename의 동적 부분에 대한 변수 :

$ pageurl = "http : // HostName/@api/deki/pages/= testPage/files/="; $ filename = "test.png";
curl -b cookie.txt -X PUT \
     --data-binary "@test.png" \
     -H "Content-Type: image/png" \    
     "http://hostname/@api/deki/pages/=TestPage/files/=test.png" \
     -0

전체 url을 구성합니다 :

$ theurl = $ pageurl. $ filename;

  1. 컬 요청을 초기화합니다 :
    curl -b cookie.txt -X PUT \
         --data-binary "@test.png" \
         -H "Content-Type: image/png" \    
         "http://hostname/@api/deki/pages/=TestPage/files/=test.png" \
         -0
    $ ch = curl_init ($ theurl);
  2. curl -b cookie.txt -X PUT \
         --data-binary "@test.png" \
         -H "Content-Type: image/png" \    
         "http://hostname/@api/deki/pages/=TestPage/files/=test.png" \
         -0
  3. 원래 명령과 일치하려면 :

    $ch = curl_init($theurl);
    ); // -시간 // 강제 HTTP/1.0 버전 curl_setopt ($ ch, curlopt_http_version, curl_http_version_1_0); // -0
  4. ... (다음과 같은 추가 코드)

    curl -b cookie.txt -X PUT \
         --data-binary "@test.png" \
         -H "Content-Type: image/png" \    
         "http://hostname/@api/deki/pages/=TestPage/files/=test.png" \
         -0
  5. 명령 줄 CURL 명령을 PHP로 성공적으로 변환 할 수 있습니다. 스크립트에서 API와 상호 작용합니다. CURL 옵션에 대한 자세한 내용은 PHP 매뉴얼을 참조하십시오 : http://www.php.net/manual/en/function.curl-setopt.php@&&]
최신 튜토리얼 더>

부인 성명: 제공된 모든 리소스는 부분적으로 인터넷에서 가져온 것입니다. 귀하의 저작권이나 기타 권리 및 이익이 침해된 경우 자세한 이유를 설명하고 저작권 또는 권리 및 이익에 대한 증거를 제공한 후 이메일([email protected])로 보내주십시오. 최대한 빨리 처리해 드리겠습니다.

Copyright© 2022 湘ICP备2022001581号-3