是否有任何WordPress登录php脚本像this one?用wordpress登录
此脚本用于使用WordPress.com帐户登录。
我按照documentation写我的脚本。但是,当我打印访问令牌时,它没有提供访问令牌。它显示它是空的。
这是我的代码来实现与WordPress.com帐户登录:
session_start();
$client_id = "2472";
$client_secret ="TaB3JPXeuJA8XsosdkMbZnuJoybxJaBF6WmDD11WFJg8QQme9fmye6l2Kxd45cpx";
$login_url = "https://public-api.wordpress.com/oauth2/authorize?client_id=$client_id&redirect_uri=http://w3.softwarecookerbd.com/wordpress.php&response_type=code";
function getToken(){
$curl = curl_init("https://public-api.wordpress.com/oauth2/token");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, array(
'client_id' => "2472",
'redirect_uri' => "http://w3.softwarecookerbd.com/wordpress.php",
'client_secret' => "TaB3JPXeuJA8XsosdkMbZnuJoybxJaBF6WmDD11WFJg8QQme9fmye6l2Kxd45cpx",
'code' => $_GET['code'], // The code from the previous request
'grant_type' => 'authorization_code'
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$auth = curl_exec($curl);
$secret = json_decode($auth);
echo "<pre>";
var_dump($secret);
exit;
$access_key = $secret->access_token;
}
if(isset($_GET["code"])&&!empty($_GET["code"])){
//$url = "https://public-api.wordpress.com/oauth2/token?client_id=$client_id&client_secret=client_secret&redirect_uri=http://w3.softwarecookerbd.com/wordpress.php&code=".$_GET['code']."&grant_type=authorization_code";
//$response = file_get_contents($url);
//echo $response;
getToken();
}else{
header("Location: ".$login_url);
}
其实,我不会在wordpress站点使用这个。我将在我的codeigniter站点中使用它,只需使用wordpress.com帐户登录即可。我遵循教程http://developer.wordpress.com/docs/oauth2/编写我的代码。当它重定向并返回代码时,但是当我调用getToken()函数来获取访问令牌时。它显示为空。如果你有任何工作演示,这对我来说很好。感谢:) – 2013-04-10 12:00:30
上述链接都是工作演示.. – 2013-04-10 12:04:30
请访问此链接https://en.gravatar.com/site/login&点击用wordpress登录。我只是想要这个代码。你会得到我正在寻找的。我不是在寻找wordpress cms站点插件的社交标志。我正在寻找与wordpress.com博客帐户登录。我希望你能明白我的意思。谢谢:) – 2013-04-11 16:16:03