我尝试使用PHP获取Dropbox访问令牌,
https://www.dropbox.com/developers-v1/core/docs#request-token
我制作了2个php文件,
auth.php:
$Header = array(
"Authorization: OAuth oauth_version=\"1.0\", oauth_signature_method=\"PLAINTEXT\", oauth_consumer_key=\"XXX\", oauth_signature=\"XXX&\"\r\n"
);
$Options = array('http' =>
array(
'method' => 'POST',
'header' => $Header,
)
);
$Context = stream_context_create($Options);
$Result = file_get_contents("https://api.dropbox.com/1/oauth/request_token", false, $Context);
echo '<a target="_blank" href="https://www.dropbox.com/1/oauth/authorize?'.$Result.'&oauth_callback=http://localhost/dropbox/access_token.php">auth</a>';
auth.php文件工作正常!并将我重定向到Dropbox网站以接受我的应用
但是当重定向到access_token.php文件时,我无法获取访问令牌!
我收到错误:无法打开流:HTTP请求失败! HTTP / 1.1
access_token.php文件:
$Options = array('http' =>
array(
'method' => 'POST',
)
);
$au = $_GET['oauth_token'];
$Context = stream_context_create($Options);
$Result = file_get_contents("https://api.dropboxapi.com/1/oauth/access_token?oauth_token=$au", false, $Context);
print_r($Result);
答案 0 :(得分:0)
在Apache中检查httpd_network_connect的selinux设置。似乎文件获取内容无法打开流。