โดย jirawoot » 29/06/2019 4:21 pm
cURL (Client for URLs)คือ เครื่องมือที่เอาไว้รับและส่งข้อมูล จาก server ผ่านโปรโตคอลต่างๆ เช่น
FTP HTTP
HTTPS เอาไว้ทดสอบ API ดู Request กับ Response ของหน้าเว็บเพื่อตรวจสอบ Header และทดสอบเรียก
webservice ของผู้ให้บริการ
การใช้งาน curl ก็จะดีตัวอย่างใช้คำสั่งดังนี้
เช่น การดึงข้อมูลจากเว็บไซต์ https://google.com
- Selection_003.png (24.29 KiB) Viewed 2953 times
คำสั่งนี้จะเป็นเรียกดูเฉพาะส่วน Header
- Selection_004.png (60.94 KiB) Viewed 2953 times
คำสั่ง
เป็นการใช้งานเพื่อเข้า 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
คำสั่ง
อ้างอิง
https://devahoy.com/blog/2016/11/getting-started-with-curl/
https://saixiii.com/what-is-curl/
https://systemsupport.itorama.com/curl/
cURL (Client for URLs)คือ เครื่องมือที่เอาไว้รับและส่งข้อมูล จาก server ผ่านโปรโตคอลต่างๆ เช่น [url=https://www.mindphp.com/คู่มือ/73-คืออะไร/2147-ftp-คืออะไร.html]FTP[/url] HTTP [url=https://www.mindphp.com/คู่มือ/73-คืออะไร/2046-http-https-คืออะไร.html]HTTPS[/url] เอาไว้ทดสอบ API ดู Request กับ Response ของหน้าเว็บเพื่อตรวจสอบ Header และทดสอบเรียก [url=https://www.mindphp.com/forums/viewtopic.php?f=29&t=58023&p=156162#p156162]webservice[/url] ของผู้ให้บริการ
การใช้งาน curl ก็จะดีตัวอย่างใช้คำสั่งดังนี้
[code]$ curl <OPTION> <URL>[/code]
เช่น การดึงข้อมูลจากเว็บไซต์ https://google.com
[attachment=1]Selection_003.png[/attachment]
คำสั่งนี้จะเป็นเรียกดูเฉพาะส่วน Header
[code]$ curl -I https://api.github.com[/code]
[attachment=0]Selection_004.png[/attachment]
คำสั่ง
[code]$ curl -u "user:pass" [URL] [/code]
เป็นการใช้งานเพื่อเข้า web ที่การ authentication
คำสั่ง
[code]$ curl -X POST -d "name=Chai&password=xxxx" [URL][/code]
การส่งข้อมูล body payload ทำได้โดย option --data หรือ -d พร้อมกับข้อมูลแบบ key=value&key2=value ซึ่งชนิดจะเป็นแบบ Content-Type: application/x-www-form-urlencoded
คำสั่ง
[code]$ curl -X POST -H "Content-Type: multipart/form-data -F "
[email protected]" -F "press=ok" [URL][/code]
อ้างอิง
https://devahoy.com/blog/2016/11/getting-started-with-curl/
https://saixiii.com/what-is-curl/
https://systemsupport.itorama.com/curl/