PHP cURL 一行?
PHP cURL One Liner?
所以我正在尝试在 PHP 脚本中执行终端 cURL 命令
有问题的命令
curl -H "public-api-token: mykeyhere" -X PUT -d "urlToShorten=google.com" https://api.shorte.st/v1/data/url
响应是JSON,如下
{"status":"ok","shortenedUrl":"http:\/\/sh.st\/XXXX"}
我把它放在我的 PHP 脚本中如下,希望它能增加更小、更有效的代码占用空间
$cmd='curl -H "public-api-token: mysecretkey" -X PUT -d "urlToShorten=google.com" https://api.shorte.st/v1/data/url';
exec($cmd,$result);
print_r($result);
然而返回的数组是空的
结果是
Array ( )
exec() returns 最后一行输出,尝试使用 shell_exec().
所以我正在尝试在 PHP 脚本中执行终端 cURL 命令
有问题的命令
curl -H "public-api-token: mykeyhere" -X PUT -d "urlToShorten=google.com" https://api.shorte.st/v1/data/url
响应是JSON,如下
{"status":"ok","shortenedUrl":"http:\/\/sh.st\/XXXX"}
我把它放在我的 PHP 脚本中如下,希望它能增加更小、更有效的代码占用空间
$cmd='curl -H "public-api-token: mysecretkey" -X PUT -d "urlToShorten=google.com" https://api.shorte.st/v1/data/url';
exec($cmd,$result);
print_r($result);
然而返回的数组是空的
结果是
Array ( )
exec() returns 最后一行输出,尝试使用 shell_exec().