How to transfer curl to php
Editor to share with you how curl to php, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!
The method of converting curl to php: 1. Through "curl-X GET-H" Content-Type:application "..." Get the status; 2, set the status; 3, through "$header= array (...)" Method it can be sent from curl to php.
This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer
How to transfer curl to PHP?
Curl command is converted to php source code
Get status:
Curl-X GET-H "Content-Type:application/json"-H "Authorization: token 4e56266f2502936e0378ea6a985dc74a5bec4280" http://user.endv.cn/v1/datastreams/plug-status/datapoint/
Return
{"status": 200, "datapoint": null}
Set statu
Curl-H "Authorization: token 6bcb3cdb69b07370f5ad73e7a856409802fdd735"-d "{\" datapoint\ ": {\" x\ ": 1}}" http://user.endv.cn/v1/datastreams/plug-status/datapoint/?deliver_to_device=true
Return
{"status": 404, "nonce": 333984364, "message": "remote device is disconnect"}
Send from curl to php
Get status:
Set status: