Twitter API 返回错误:34 (404) [英] Twitter API returning Error: 34 (404)

查看:63
本文介绍了Twitter API 返回错误:34 (404)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 TwitterAuth0 从 Twitter API 返回美国的热门话题,但是我得到了,{"errors":[{"message":"Sorry, that page does not exist","code":34}]} 结果.我的代码如下:

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);

我的实际凭据在密钥/秘密中,目前我在 twitter 应用程序上的回调 url 是我返回的提要页面,这是正确的吗?(所以实际页面才能看到提要)

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.

推荐答案

找出问题:

获取需要的部分:

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

代替:

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

这篇关于Twitter API 返回错误:34 (404)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆