หน้า 1 จากทั้งหมด 1

cURL คืออะไร

โพสต์แล้ว: 29/06/2019 4:21 pm
โดย jirawoot
cURL (Client for URLs)คือ เครื่องมือที่เอาไว้รับและส่งข้อมูล จาก server ผ่านโปรโตคอลต่างๆ เช่น FTP HTTP HTTPS เอาไว้ทดสอบ API ดู Request กับ Response ของหน้าเว็บเพื่อตรวจสอบ Header และทดสอบเรียก webservice ของผู้ให้บริการ
การใช้งาน curl ก็จะดีตัวอย่างใช้คำสั่งดังนี้

โค้ด: เลือกทั้งหมด

$ curl <OPTION> <URL>
เช่น การดึงข้อมูลจากเว็บไซต์ https://google.com
Selection_003.png
Selection_003.png (24.29 KiB) Viewed 2942 times
คำสั่งนี้จะเป็นเรียกดูเฉพาะส่วน Header

โค้ด: เลือกทั้งหมด

$ curl -I https://api.github.com
Selection_004.png
Selection_004.png (60.94 KiB) Viewed 2942 times
คำสั่ง

โค้ด: เลือกทั้งหมด

$ curl -u "user:pass" [URL] 
เป็นการใช้งานเพื่อเข้า web ที่การ authentication
คำสั่ง

โค้ด: เลือกทั้งหมด

$ curl -X POST -d "name=Chai&password=xxxx" [URL]
การส่งข้อมูล body payload ทำได้โดย option --data หรือ -d พร้อมกับข้อมูลแบบ key=value&key2=value ซึ่งชนิดจะเป็นแบบ Content-Type: application/x-www-form-urlencoded
คำสั่ง

โค้ด: เลือกทั้งหมด

$ curl -X POST -H "Content-Type: multipart/form-data -F "[email protected]" -F "press=ok" [URL]
อ้างอิง
https://devahoy.com/blog/2016/11/getting-started-with-curl/
https://saixiii.com/what-is-curl/
https://systemsupport.itorama.com/curl/

Re: cURL คืออะไร

โพสต์แล้ว: 06/10/2019 11:09 pm
โดย mindphp
การใช้ option output ของ curl
viewtopic.php?f=29&t=58335

เร็วๆ นี้ติดตาม การใช้ Curl ด้วย php ฟังก์ชั่น
https://www.mindphp.com/%E0%B8%84%E0%B8 ... 9-php.html

Re: cURL คืออะไร

โพสต์แล้ว: 20/11/2020 11:24 pm
โดย mindphp
วิธีติดตั้ง curl บน Ubuntu
viewtopic.php?f=27&t=71060