我只想获得“将用户连接到我的推特应用”的链接。
这是我的代码:
<?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->oauth2("request_token", ["oauth_callback"=>$callback]); // display => null
$content = $oauth->url("request_token", ["oauth_callback"=>$callback]); // display https://api.twitter.com/request_token?oauth_callback=http%3A%2F%2F127.0.0.1%3A8080%2Ffront%2F1_index.html => but onclick twitter says to me "page not found"
$content = $oauth->oauth("1.1/request_token", "oauth_callback"=>$callback]); // display => page not found by twitter
$content = $oauth->oauth("1/request_token", ["oauth_callback"=>$callback]); // display => "The Twitter REST API v1 is no longer active. Please migrate to API v1.1" ... what did i tried before ? ..
$content = $oauth->get("request_token", ["oauth_callback"=>callback]); // display => Sorry, that page does not exist
$content = $oauth->post("request_token", ["oauth_callback"=>callback]); // display => Sorry, that page does not exist
$content = $oauth->oauth("request_token", ["oauth_callback"=>callback]); // display => page not found
编辑:
$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_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上有一个工作示例正在努力获取重定向链接吗?