Twitter API returning Error: 34 (404)

元气小坏坏 提交于 2020-02-25 04:03:47

问题


I am trying to returning trending topics in the USA from the twitter API using TwitterAuth0 however I am getting, {"errors":[{"message":"Sorry, that page does not exist","code":34}]} as a result. My code is as following:

session_start();
require_once("twitteroauth-master/autoload.php"); //Path to twitteroauth library
use Abraham\TwitterOAuth\TwitterOAuth;

$id = "23424977";
$consumerkey = "XXX";
$consumersecret = "XXX";
$accesstoken = "XXX";
$accesstokensecret = "XXX";

function getToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) {
    $connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
    return $connection;
}

$connection = getToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);

$tweets = $connection->get("https://api.twitter.com/1.1/trends/place.json?id=".$id);
echo json_encode($tweets);

My actual credentials are in the keys/secrets, currently my callback url on twitter apps is the page of the feed I am returning, is this correct? (So the acutal page to see the feed)

Any help on this error is appreciated.


回答1:


Figured out the issue:

Get piece needed to be:

$tweets = $connection->get("trends/place", [ "id" => 23424977 ]);

instead of:

$tweets = $connection->get("https://api.twitter.com/1.1/trends/place.json?id=".$id);


来源:https://stackoverflow.com/questions/39352627/twitter-api-returning-error-34-404

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!