我在验证时遇到问题!我使用以下代码获得401
<script src="codebird.js"></script>
<script>
var cb = new Codebird;
cb.setConsumerKey("xxx", "xxx");
function autht(){
cb.__call(
"oauth_requestToken",
{oauth_callback: "http://snipleecast.com/index2.php"},
function (reply,rate,err) {
if (err) {
console.log("error response or timeout exceeded" + err.error);
}
if (reply) {
// stores it
cb.setToken(reply.oauth_token, reply.oauth_token_secret);
// gets the authorize screen URL
cb.__call(
"oauth_authorize",
{},
function (auth_url) {
window.codebird_auth = window.open(auth_url);
}
);
}
}
);
}
<?php if ( isset ( $_GET['oauth_verifier'] ) ){
?>
// assign stored request token parameters to codebird here
// ...
cb.setToken(something, something2);
cb.__call(
"oauth_accessToken",
{
oauth_verifier: '<?php echo $_GET['oauth_verifier']; ?>'
},
function (reply, rate, err) {
if (err) {
console.log("error response or timeout exceeded" + err.error);
}
if (reply) {
cb.setToken(reply.oauth_token, reply.oauth_token_secret);
alert('<?php echo $_GET['oauth_verifier']; ?>');
}
// if you need to persist the login after page reload,
// consider storing the token in a cookie or HTML5 local storage
}
);
<?php
}
?>
我点击了一个按钮,它启动了twitter oauth页面,但是一旦它返回到我的主页,没有任何反应:(只是401错误。
IDK我做错了什么:(
答案 0 :(得分:0)
没关系,对不起大家搞清楚了!看起来我不见了
"oauth_accessToken",
{
oauth_token: '<?php echo $_GET['oauth_token']; ?>',
oauth_verifier: '<?php echo $_GET['oauth_verifier']; ?>'
},