【发布时间】:2020-10-12 20:25:50
【问题描述】:
我正在使用以下 cURL 请求从一个帐户获取所有推文:
$url = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
$requestMethod = 'GET';
$getfield = '?screen_name=heregoestheaccount&tweet_mode=extended&count=50';
$twitter = new TwitterAPIExchange($settings);
$twitter->setGetfield($getfield);
$twitter->buildOauth($url, $requestMethod);
$response = $twitter->performRequest(true, array(CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_SSL_VERIFYPEER => 0));
$tweets = json_decode($response, true);
我现在得到以下数组:
array (size=26)
'created_at' => string 'Fri Sep 25 12:05:51 +0000 2020' (length=30)
'id' => int 1309464126494846976
'id_str' => string '1309464126494846976' (length=19)
'full_text' => string '[ #Esports ]
On Sunday 27.09.2020 at 1 p.m. the First Division Qualifier for the Rainbow Six: Siege Fall Season 2020 will start! Our team will fight for its slot in the first division.
We wish all the best for their first competition in the noetic team!
#noeticBLAST ???????? (length=302)
'truncated' => boolean false
'display_text_range' =>
array (size=2)
0 => int 0
1 => int 272
'entities' =>
...
我的问题是,在渲染推文的full_text 时,文本不遵循原始缩进,因为它是这样渲染的。
如何显示推文的原始缩进?
编辑:我有以下 HTML 来显示文本:
<div class="col-sm-12 col-md-7">
<p>
<?= $tweet['full_text']; ?>
</p>
</div>
编辑2:根据@Pascal 评论,我在<p> 中添加了<pre> 标签。
显示的内容如下:
但这不是我想要的,因为我不希望用户必须滚动才能看到文本。
【问题讨论】:
-
像这样
<pre>...</pre>把它放在pre tag html中并做一些css -
你能告诉我在编辑之后我应该把它放在哪个地方吗?
-
在你的 p 标签里面,比如
<p><pre><?= $tweet['full_text']; ?></pre></p> -
请检查我在帖子中添加的内容:)
-
我知道你想要什么,为了完成任务,你应该创建自定义格式的文本来完成这项工作。这是一篇可能会引起兴趣的帖子stackoverflow.com/questions/11533214/…