如何解决这个问题 file_get_contents(): 文件名不能为空?
How can resolve this issue file_get_contents(): Filename cannot be empty?
我正在使用 XERO API 与我的项目集成,而我正在使用 consumer_key、consumer_secret、rsa_private_key、rsa_public_key 进行身份验证使用 xero 帐户,我生成 rsa_private_key 和 rsa_public_key 并在获取这些时放置在 storage/app/certificates 目录中keys 我正在使用 file_get_contents 函数获取密钥但面临错误 file_get_contents(): 文件名不能为空,我该如何解决这个问题?
My File paths
Xero.php
私有静态函数get_config(){
return $config = [
'oauth' => [
'callback' => '',
'consumer_key' => config('constants.XERO_CONSUMER_KEY'),
'consumer_secret' => config('constants.XERO_CONSUMER_SECRET'),
'rsa_private_key' => file_get_contents(config('constants.XERO_PRIVATE_KEY_CERTIFICATE_FILE_PATH')),
'rsa_public_key' => file_get_contents(config('constants.XERO_PUBLIC_KEY_CERTIFICATE_FILE_PATH')),
],
];
}
config/constants/dev_constants.php
<?php
$xero_constants = [
"XERO_CONSUMER_KEY" => "***",
"XERO_CONSUMER_SECRET" => "***",
"XERO_PRIVATE_KEY_CERTIFICATE_FILE_PATH" => dirname(__FILE__,3)."/storage/app/certificates/privatekey.pem",
"XERO_PUBLIC_KEY_CERTIFICATE_FILE_PATH" => dirname(__FILE__,3)."/storage/app/certificates/publickey.cer",
];
?>
您正在通过 :
获取配置
config('constants.XERO_PUBLIC_KEY_CERTIFICATE_FILE_PATH')
会returnnull
。因为config没有return
。您需要编辑 dev_constants.php
:
<?php
return [
"XERO_CONSUMER_KEY" => "***",
"XERO_CONSUMER_SECRET" => "***",
"XERO_PRIVATE_KEY_CERTIFICATE_FILE_PATH" => dirname(__FILE__,3)."/storage/app/certificates/privatekey.pem",
"XERO_PUBLIC_KEY_CERTIFICATE_FILE_PATH" => dirname(__FILE__,3)."/storage/app/certificates/publickey.cer",
];
config('constants.dev_constants.XERO_PUBLIC_KEY_CERTIFICATE_FILE_PATH')
我正在使用 XERO API 与我的项目集成,而我正在使用 consumer_key、consumer_secret、rsa_private_key、rsa_public_key 进行身份验证使用 xero 帐户,我生成 rsa_private_key 和 rsa_public_key 并在获取这些时放置在 storage/app/certificates 目录中keys 我正在使用 file_get_contents 函数获取密钥但面临错误 file_get_contents(): 文件名不能为空,我该如何解决这个问题?
My File paths
Xero.php
私有静态函数get_config(){
return $config = [
'oauth' => [
'callback' => '',
'consumer_key' => config('constants.XERO_CONSUMER_KEY'),
'consumer_secret' => config('constants.XERO_CONSUMER_SECRET'),
'rsa_private_key' => file_get_contents(config('constants.XERO_PRIVATE_KEY_CERTIFICATE_FILE_PATH')),
'rsa_public_key' => file_get_contents(config('constants.XERO_PUBLIC_KEY_CERTIFICATE_FILE_PATH')),
],
];
}
config/constants/dev_constants.php
<?php
$xero_constants = [
"XERO_CONSUMER_KEY" => "***",
"XERO_CONSUMER_SECRET" => "***",
"XERO_PRIVATE_KEY_CERTIFICATE_FILE_PATH" => dirname(__FILE__,3)."/storage/app/certificates/privatekey.pem",
"XERO_PUBLIC_KEY_CERTIFICATE_FILE_PATH" => dirname(__FILE__,3)."/storage/app/certificates/publickey.cer",
];
?>
您正在通过 :
获取配置config('constants.XERO_PUBLIC_KEY_CERTIFICATE_FILE_PATH')
会returnnull
。因为config没有return
。您需要编辑 dev_constants.php
:
<?php
return [
"XERO_CONSUMER_KEY" => "***",
"XERO_CONSUMER_SECRET" => "***",
"XERO_PRIVATE_KEY_CERTIFICATE_FILE_PATH" => dirname(__FILE__,3)."/storage/app/certificates/privatekey.pem",
"XERO_PUBLIC_KEY_CERTIFICATE_FILE_PATH" => dirname(__FILE__,3)."/storage/app/certificates/publickey.cer",
];
config('constants.dev_constants.XERO_PUBLIC_KEY_CERTIFICATE_FILE_PATH')