1

我正在通过 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);

如何使换行符发送到?

PS对不起我的英语

4

2 回答 2

0

尝试使用nl2br功能

$attachment =  array(
'access_token' => $token,
'message' => nl2br($postMessage)
);
于 2013-08-06T15:33:38.730 回答
0

我知道这个老了,但如果它对其他人有帮助,我有更好的运气json_encode/json_decode

于 2020-03-09T15:41:40.940 回答