dsfsdf5646 2017-01-26 15:40
浏览 451

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

I ran

a cURL on my Terminal

Note : state = 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=

I got this reponse back

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

Note : state = b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7


PHP

Note : state = b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7

$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); 

Note : state != b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7

Note : state = 12345678-256d-425d-808b-1e05d2aa3d72

< Location: https://testserver.sitenets.com/user/secure/dashboard?code=zvk495dsnq1ycLKZgN8oqfFxQogg2oql&state=12345678-256d-425d-808b-1e05d2aa3d72

When I run shell_exec($cmd), my state always come back different the one that I submitted. How is this possible ?

Is it caching somewhere on my local machine ? Should I clear something ?

Why shell_exec() return slightly different result than if I would have do it directly on Terminal ?

I even tried using exec(), same result.

How would one go about and debug this further ?

What elses should I look into ?


I'm opening to any suggestions at this moment.

Any hints / suggestions / helps on this be will be much appreciated !

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog
    • ¥15 Excel发现不可读取的内容
    • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
    • ¥20 yolov5自定义Prune报错,如何解决?