0

如果我在 Bash (ssh) 中正常运行 curl 命令,它会显示实例创建的 json 输出,例如 id,os,ram extra 但是如果我在 PHP 中提供相同的内容,则会显示上述错误 PHP 代码:

<?php
echo "Creating Instance...";
$a = shell_exec(`curl -s "https://api.vultr.com/v2/instances" -X POST -H "Authorization: Bearer $vultr_api_key" -H "Content-Type: application/json" --data '{"sshkey_id":["f3b1a5da-7f3b-4f35-8801-074b313cd1b1"],"region":"icn","plan":"vc2-1c-1gb","os_id":"167"}'`);

输出 :

Creating Instance...sh: {instance:id:2a2cd864-3896-4aed-9e2c-9d1df3a2e4c5}: command not found
I need to store the output in $a and use the json decode but giving the following error

错误 :

 Creating Instance...sh: {instance:id:2a2cd864-3896-4aed-9e2c-9d1df3a2e4c5}: command not found

如何解决这个问题?

注意:正在创建实例!

4

0 回答 0