2013-08-06 39 views
0

我張貼喜歡通過PHP捲曲下一個Facebook的消息後失蹤:PHP換行符被張貼

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.對不起,我的英語

+0

嘗試使用\ n在$ postMessage的,也許它的工作原理 – JohannesB

+0

或者,如果有什麼@Rsauxil說不行,請嘗試
標籤? – leftclickben

+0

運行你的內容的nl2br函數或樣式包含白色空間的元素:pre-wrap – Orangepill

回答

0

嘗試使用nl2br功能

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

好吧,這個「解決方法」工作:'$ postMessage = nl2br($ _ POST [「message」]); $ postMessage = str_replace(「
」,「\ n」,$ postMessage);'有沒有更好的方法來做到這一點? – Jay