PHP-发布后缺少换行符

问题描述 投票:1回答:2

我正在通过PHP cURL将类似下面的消息发布到Facebook:

Hello world

This is a test

#hash

[Facebook墙上的条目缺少换行符-文本看起来像这样:

Hello world This is a test #hash

这是我的代码:

$attachment =  array(
'access_token' => $token,
'message' => $postMessage
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/'.$profileID.'/feed');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
$result = curl_exec($ch);

如何将换行符发送到?

P.S。对不起,我的英语

php curl line-breaks
2个回答
0
投票

尝试使用nl2br功能


0
投票

我知道这个年龄,但是如果可以帮助其他人,那么json_encode / json_decode会更好。

© www.soinside.com 2019 - 2024. All rights reserved.