Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.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警告消息公开OAuth应用程序机密_Php_Security_Error Handling - Fatal编程技术网

PHP警告消息公开OAuth应用程序机密

PHP警告消息公开OAuth应用程序机密,php,security,error-handling,Php,Security,Error Handling,我正在使用OAuth2为应用程序授权Facebook帐户。我刚刚发现,如果访问令牌请求失败,file\u get\u contents将显示完整的请求URL,其中包含机密应用程序id(client\u id/client\u secret)等敏感数据。 如何处理这些事情?有没有一种方法可以显示警告消息但不暴露这些路径 Warning: file_get_contents(https://graph.facebook.com/oauth/access_token?client_id=123&

我正在使用OAuth2为应用程序授权Facebook帐户。我刚刚发现,如果访问令牌请求失败,
file\u get\u contents
将显示完整的请求URL,其中包含机密应用程序id(client\u id/client\u secret)等敏感数据。 如何处理这些事情?有没有一种方法可以显示警告消息但不暴露这些路径

Warning: file_get_contents(https://graph.facebook.com/oauth/access_token?client_id=123&redirect_uri=https%3A%2F%2Fwww.example.com%2Foauth%2Ffacebook.php&client_secret=123&code=123) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in oauth/facebook.php on line 113

在php中使用try-catch块轻轻地处理错误。因为您使用的是FacebookOAuth,所以只需在try-catch中包含以下方法/函数

试试看{
“…facebook oauth函数在此…”
}
捕获(例外$e){
echo$e->getMessage();
}

请让我知道这是否解决了您的问题

问候,, HBK