所以我找到了一个Python
代码,它正在做我想做的事情,但是我找不到一种方法让它在PHP中工作(我已经尝试过多次翻译它们)
以下是Python代码:
def restpost(url, payload, head=None):
if head is not None:
r = s.post(url, data=payload, timeout=90, stream=False, headers=head, verify=pem)
else:
r = s.post(url, data=payload, timeout=90, stream=False, verify=pem)
commit_data = r.json()
return commit_data
restpost(URL, json.dumps(switch))
所以,我知道URL,这里,json.dumps(switch))
是{"intrusion_settings": {"active_mode": "away"}}
如何在PHP中实现这一点?我尝试了很多方法,但都不管用。即使请求成功发送,它也无法工作
如果您想更深入地了解我正在尝试做的事情,下面是我想在PHP中执行的python代码:https://github.com/dynasticorpheus/gigasetelements-cli
(仅限切换部分)
如果你能帮忙,谢谢你
您必须使用
json_encode
函数示例
可能的解决方案
手册
Executable code
PHP: json_encode
PHP: cURL
相关问题 更多 >
编程相关推荐