Php TwitterOAuth Api“;获取登录btn“;
我只想获得“将用户连接到我的twitter应用”的链接 这是我的密码:Php TwitterOAuth Api“;获取登录btn“;,php,twitter,oauth,oauth-2.0,twitter-oauth,Php,Twitter,Oauth,Oauth 2.0,Twitter Oauth,我只想获得“将用户连接到我的twitter应用”的链接 这是我的密码: <?php require_once "../../../utils/UtilsIncluder.php"; use Abraham\TwitterOAuth\TwitterOAuth; session_start(); $consumer_key = 'something'; $consumer_secret = 'somethingother'; $callback = "http://127.0.0.1:8
<?php
require_once "../../../utils/UtilsIncluder.php";
use Abraham\TwitterOAuth\TwitterOAuth;
session_start();
$consumer_key = 'something';
$consumer_secret = 'somethingother';
$callback = "http://127.0.0.1:8080/front/index.html";
$oauth = new TwitterOAuth($consumer_key, $consumer_secret);
$content = $oauth->oauth("request_token", ["oauth_callback"=>$callback]);
var_dump($content);
echo "<a href='".$content."'>Authorize our app</a>";
编辑:
$content = $oauth->oauth("oauth/request_token", ["oauth_callback"=>callback]); // display => Uncaught exception 'Abraham\TwitterOAuth\TwitterOAuthException' with message 'Request token failed'
$content = $oauth->post("oauth/request_token", ["oauth_callback"=>callback]); // display => Sorry, that page does not exist
$content = $oauth->oauth2("oauth/request_token", ["oauth_callback"=>callback]); // display => Bad Authentication data.
$content = $oauth->oauth("1.1/oauth/request_token", ["oauth_callback"=>$callback]); // display Bad Authentication data.
$content = $oauth->post("1.1/oauth/request_token", ["oauth_callback"=>$callback]); // display => Sorry, that page does not exist
$content = $oauth->oauth2("1.1/oauth/request_token", ["oauth_callback"=>$callback]); // display => Sorry, that page does not exist
$oauth->oauth(“oauth/request\u token”
似乎很有趣,所以我尝试:
try {
$content = $oauth->oauth("oauth/request_token", ["oauth_callback"=>$callback]);
} catch (Exception $e) {
var_dump($e->getMessage());
}
// display => Request token failed (thx for details ^^)
嗯,也许我做错了什么?有人用TwitterOAuth做过一个例子来获取重定向链接吗?好的,
我看到我必须在twitter应用程序中将我的回调url指定为()。现在它工作得很好
好的,
我看到我必须在twitter应用程序中将我的回调url指定为()。现在它工作得很好
我相信路径(第一个参数)应该是
“oauth/request\u token”
@PatrickQ我更新了我的问题,没有更好的效果:/@PatrickQ根据oauth基金会的源代码:“向API发出/oauth/*请求。”理论上我不需要指定“oauth/”好的。我从来没有使用过这个库。我只是根据oauth()
函数的示例提出建议,在页面的中间部分,可能我没有理解文档。我认为路径(第一个参数)应该是“oauth/request\u token”
@PatrickQ我更新了我的问题,没有更好的效果:/@PatrickQ根据oauth基金会的源代码:“向API发出/oauth/*请求”。理论上我不需要指定“oauth/”。好吧。我从来没有使用过该库。我只是根据为oauth()提供的示例提出建议
功能在页面右下半部分,可能我不理解文档
try {
$content = $oauth->oauth("oauth/request_token", ["oauth_callback"=>$callback]);
} catch (Exception $e) {
var_dump($e->getMessage());
}
// display => Request token failed (thx for details ^^)