Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过PHP shell_exec()执行cURL返回与通过命令行执行cURL不同的响应 我跑_Php_Macos_Shell_Unix_Curl - Fatal编程技术网

通过PHP shell_exec()执行cURL返回与通过命令行执行cURL不同的响应 我跑

通过PHP shell_exec()执行cURL返回与通过命令行执行cURL不同的响应 我跑,php,macos,shell,unix,curl,Php,Macos,Shell,Unix,Curl,我终端上的卷发 注意:状态=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7 curl -c session_cookies.txt "https://login.uat.site.be/openid/oauth/authorize?client_id=site&state=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7&nonce5ba13e5f-256d-425d-808b-1e05d2aa3d72&resp

我终端上的卷发

注意:状态=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7

curl -c session_cookies.txt "https://login.uat.site.be/openid/oauth/authorize?client_id=site&state=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7&nonce5ba13e5f-256d-425d-808b-1e05d2aa3d72&response_type=code&claims=%7B%22id_token%22%3A%7B%22http%3A%2F%2Fsite.be%2Fclaims%2Froles%22%3Anull%7D%7D" 2>/dev/null| curl -v -b session_cookies.txt -L -H "Content-Type: application/x-www-form-urlencoded" -v -d 'j_username=manager-sitelogin@gmail.com&j_password=site1' "https://login.uat.site.be/openid/login.do" 2>&1 >/dev/null | grep Location | grep code=
$cmd = 'curl -c session_cookies.txt "https://login.uat.site.be/openid/oauth/authorize?client_id=site&state=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7&nonce5ba13e5f-256d-425d-808b-1e05d2aa3d72&response_type=code&claims=%7B%22id_token%22%3A%7B%22http%3A%2F%2Fsite.be%2Fclaims%2Froles%22%3Anull%7D%7D" 2>/dev/null| curl -v -b session_cookies.txt -L -H "Content-Type: application/x-www-form-urlencoded" -v -d 'j_username=manager-sitelogin@gmail.com&j_password=site1' "https://login.uat.site.be/openid/login.do" 2>&1 >/dev/null | grep Location | grep code=';


$result = shell_exec($cmd);

dd($result); 

我得到了回复

< Location: https://testserver.sitenets.com/user/secure/dashboard?code=zvk495dsnq1ycLKZgN8oqfFxQogg2oql&state=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7

注意:状态!=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7

curl -c session_cookies.txt "https://login.uat.site.be/openid/oauth/authorize?client_id=site&state=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7&nonce5ba13e5f-256d-425d-808b-1e05d2aa3d72&response_type=code&claims=%7B%22id_token%22%3A%7B%22http%3A%2F%2Fsite.be%2Fclaims%2Froles%22%3Anull%7D%7D" 2>/dev/null| curl -v -b session_cookies.txt -L -H "Content-Type: application/x-www-form-urlencoded" -v -d 'j_username=manager-sitelogin@gmail.com&j_password=site1' "https://login.uat.site.be/openid/login.do" 2>&1 >/dev/null | grep Location | grep code=
$cmd = 'curl -c session_cookies.txt "https://login.uat.site.be/openid/oauth/authorize?client_id=site&state=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7&nonce5ba13e5f-256d-425d-808b-1e05d2aa3d72&response_type=code&claims=%7B%22id_token%22%3A%7B%22http%3A%2F%2Fsite.be%2Fclaims%2Froles%22%3Anull%7D%7D" 2>/dev/null| curl -v -b session_cookies.txt -L -H "Content-Type: application/x-www-form-urlencoded" -v -d 'j_username=manager-sitelogin@gmail.com&j_password=site1' "https://login.uat.site.be/openid/login.do" 2>&1 >/dev/null | grep Location | grep code=';


$result = shell_exec($cmd);

dd($result); 
注意:状态=12345678-256d-425d-808b-1e05d2aa3d72

<位置:https://testserver.sitenets.com/user/secure/dashboard?code=zvk495dsnq1ycLKZgN8oqfFxQogg2oql&state=12345678-256d-425d-808b-1e05d2aa3d72
当我运行
shell\u exec($cmd)
时,我的状态总是与我提交的状态不同。这怎么可能

它是否缓存在本地计算机上的某个位置?我应该澄清点什么吗


为什么
shell\u exec()
返回的结果与直接在终端上执行的结果略有不同?我甚至尝试使用了
exec()
,同样的结果。

对于
$cmd='curl-c session\u cookies.txt…
session\u cookies文件必须在程序的当前工作目录中。当您执行php代码时也是这样吗?我希望这些不是真实的用户名/密码首先,您可能对如何运行脚本有问题。session_cookies.txt可能会有所不同,因为您似乎是以php服务器用户的身份而不是终端用户的身份运行该命令,所以它可能位于不同的位置。是我还是您正在返回nonce?这不可能是巧合。@fvu:观察得好!!,我在控制器的1中运行shell_exec,session.txt在我的public/目录中。我想,我应该包括session.txt的绝对路径???你觉得呢?那绝对值得一试。另外,别忘了,你没有义务掏钱。