繁体   English   中英

Twitter API abraham\\TwitterOAuth 中的新行

[英]New line in twitter API abraham\TwitterOAuth

在实施必要的更改以支持表情符号到我的数据库后,我遇到了这个问题,我似乎无法在Twitter新行来发布新tweet

假设我有以下代码:

$parameters = [
    'status'    => "Foo. \n New line",
];

Twitter将正确呈现它,因为它位于" 。如果我碰巧执行以下操作:

$parameters = [
    'status'    => 'Foo. \n New line',
];

Twitter将呈现Foo. \\n New Line Foo. \\n New Line

当我需要使用新的行终止符\\n更新状态时,我的问题就开始了。

$tweet = $dataFromDatabase;
$parameters = [
    'status' => $tweet
]

Twitter将呈现来自数据库的文字字符串(在本例中我们可以假设它是Foo. \\n New Line )。

我想问题来自于使用'而不是"

问题

如何让Twitter读取$tweet变量正确显示格式正确的内容?

我尝试了以下解决方案但没有成功:

$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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM