首页 > 解决方案 > 渲染 twitter 标准搜索 api

问题描述

我如何呈现 twitter 标准搜索 api

参考:

https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html

我的代码

require_once('TwitterAPIExchange.php');

$settings = array('oauth_access_token' => "XXX",'oauth_access_token_secret' => "XXX",'consumer_key' => "XXX",'consumer_secret' => "XXX");

$url = "https://api.twitter.com/1.1/search/tweets.json";

$requestMethod = "GET";

$getfield = "?q=#XXX from:XXX";

$twitter = new TwitterAPIExchange($settings);

$string = json_decode($twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest(),$assoc = TRUE);

if($string["errors"][0]["message"] != "") {echo "<h3>Sorry, there was a problem.</h3><p>Twitter returned the following error message:</p><p><em>".$string[errors][0]["message"]."</em></p>";exit();}

var_dump($string);

它给了我类似于上面参考的回应

我的问题是如何渲染它?我找不到任何关于此的文档/示例?

像嵌入式时间线和 oEmbedAPI

参考:

https://developer.twitter.com/en/docs/twitter-for-websites/timelines/overview https://developer.twitter.com/en/docs/twitter-for-websites/timelines/guides/oembed-api

标签: phptwitter

解决方案


推荐阅读