Twitter 搜索 API 没有结果 [英] Twitter Search API no results

查看:83
本文介绍了Twitter 搜索 API 没有结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 PHP 脚本,它使用 Twitter 搜索 API 来查找与搜索匹配的推文,但由于某种原因不再工作并且没有返回任何结果.

I have a PHP script that uses the Twitter Search API to find tweets matching a search but for some reason is no longer working and is not returning any results.

有人知道出了什么问题吗?

Does anyone know what is going wrong?

<?php   

$search=json_decode(file_get_contents('https://search.twitter.com/search.json?q='.urlencode($_GET[q]).'%20vine.co%2Fv%2F&result_type=recent&include_entities=1&rpp=9&page='.$_GET[page]));
foreach($search->results as $result){
 foreach($result->entities->urls as $url){
   echo $url->expanded_url;
 }
}

?>

推荐答案

A Bug

当前 1.0 API 中存在错误 - 请参阅此错误报告.无论如何,未经身份验证的请求将在四天内停止工作.

Twitter 要求您使用经过身份验证的请求 (OAuth),因为五天后,v1.0 API 将完全删除.

Twitter requires you to use authenticated requests (OAuth) because, five days from now, the v1.0 API will be removed completely.

这对您来说意味着一个简单的:

What this means for you is that a simple:

file_get_contents( . . . )

...好吧,对于 1.0 api,它只会停止返回数据!五天后,您将无法再使用它!

... well, for the 1.0 api, it'll just stop returning data! Five days from now, you won't be able to use that any more!

请参阅我今天发布的这篇文章,了解一些背景信息和证明API 移除日期(从现在起五天).

See this post I posted today for a little background information and proof of the API removal date (five days from now).

这篇文章 介绍了如何使用 Twitter 的 1.1 API 发出经过身份验证的请求.如果您使用 这个库 并且只用几行代码来制作实际请求.

See this post for a walk through of how to make authenticated requests using Twitter's 1.1 API. It's pretty simple if you use this library and only a few lines of code to make the actual request.

这篇关于Twitter 搜索 API 没有结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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