douan2478 2010-10-13 09:28
浏览 80

如何在Facebook图形API上添加换行符或回车到描述

It sounds like a pretty simple question but I can find the answer no where.

I have a post from a textarea. and I want to use the current facebook php library to do the following...

$description = $_POST['textarea_description'];

//magic happens

$attachment =  array(
'access_token' => $token,
'message' => "$title",
'picture' => "$image_url",
'link' => "$action_link",
'name' => "$action_label",
'caption' => "$caption",
'actions' => $action_json,
'description' => "$description",
 );

$facebook->api('/'.$my_uid.'/feed', 'POST', $attachment);

and have it work. Right now it seems to ignore

<br> <br /> 
  
 

but I am sure I might have done something to screw up my testing.. I just need to replace 'magic happens' with something that works. Right now it just converts all of the newlines I am throwing at it to spaces.. Pretty frustrating. Someone on the facebook forums suggested addslashed() of all things... but that did not seem to work for me

Thanks, -FT

  • 写回答

2条回答 默认 最新

  • duanlei1957 2010-12-22 15:48
    关注

    If your lines of text are long enough, and you replace each space in each line with a non-breaking space ("&nbsp;") and put a regular space at the end of the line, then this will have the effect of forcing each line onto a new line, e.g.

    This&nbsp;is&nbsp;some&nbsp;example&nbsp;text&nbsp;etc. This&nbsp;is&nbsp;some&nbsp;example&nbsp;text&nbsp;etc. This&nbsp;is&nbsp;some&nbsp;example&nbsp;text&nbsp;etc.

    If any lines are too short, you can pad them out with &nbsp; chars

    评论

报告相同问题?

悬赏问题

  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害