[英]New line in twitter API abraham\TwitterOAuth
After implementing the necessary changes to support emojis into my database I have came across this problem where I can't seem to fit a new line into posting a new tweet
to Twitter
.在实施必要的更改以支持表情符号到我的数据库后,我遇到了这个问题,我似乎无法在Twitter
新行来发布新tweet
。
Lets suppose I have the following code:假设我有以下代码:
$parameters = [
'status' => "Foo. \n New line",
];
Twitter
will render it correctly since it is in "
. If I happen to do the following: Twitter
将正确呈现它,因为它位于"
。如果我碰巧执行以下操作:
$parameters = [
'status' => 'Foo. \n New line',
];
Twitter
will render Foo. \\n New Line
Twitter
将呈现Foo. \\n New Line
Foo. \\n New Line
. Foo. \\n New Line
。
My questions starts when I need to update the status with a new line terminator \\n
in it.当我需要使用新的行终止符\\n
更新状态时,我的问题就开始了。
$tweet = $dataFromDatabase;
$parameters = [
'status' => $tweet
]
Twitter
will render the literal string coming from the database (which in this example we can suppost it is Foo. \\n New Line
). Twitter
将呈现来自数据库的文字字符串(在本例中我们可以假设它是Foo. \\n New Line
)。
I suppose the problem comes from using '
instead of "
.我想问题来自于使用'
而不是"
。
Question问题
How I can make Twitter
read the $tweet
variable correctly displaying the content formated correctly?如何让Twitter
读取$tweet
变量正确显示格式正确的内容?
I have tried the following solutions without success:我尝试了以下解决方案但没有成功:
$parameters = [
'status' => '"'. $tweet .'"',
];
$parameters = [
'status' => addslashes($tweet),
];
$parameters = [
'status' => "{$tweet}",
];
如果要发布带有换行符的新消息,在 PHP 中,代码为:
$parameters = array("status" => "Content of the first line" . chr(13) . chr(10) . "Content of the second line");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.