第一步:获取畅言数据并转为数组
$cy_data = htmlspecialchars_decode(I('data'));//获取畅言返回数据,并转码 $data = json_decode($cy_data,true);//将JSON转为数组
第二步,根据自身业务需求完成后续操作
畅言返回的数组格式为:
Array ( [comments] => Array ( [0] => Array ( [apptype] => [attachment] => Array() [channelid] => [channeltype] => //1为评论框直接发表的评论,2为第三方回流的评论 [cmtid] => //评论唯一ID [content] => //评论内容 [ctime] => //评论时间 [from] => //评论来源 [ip] => //发布ip [opcount] => //评论被踩次数 [referid] => [replyid] => //回复的评论ID,没有为0 [score] => [spcount] => //评论被顶次数 [status] => [user] => Array ( [nickname] => //发布者昵称 [sohuPlusId] => [usericon] => //发布者头像(留空使用默认头像) [userid] => //发布者ID [userurl] => //发布者主页地址(可留空) ) [useragent] => //浏览器信息 ) ) [metadata] => {"local_ip":"127.0.0.1"} [sourceid] => //文章Id [title] => //文章标题 [ttime] => //文章创建时间 [url] => //文章url )
完整的Json数据为:
{ "title":"123", //文章标题 "url":"http://localhost/?p=9", //文章url "ttime":1401327899094, //文章创建时间 "sourceid":"9", //文章Id "parentid":"0", //文章所属专辑的ID,多个的话以,号分隔 "categoryid":"", //文章所属频道ID(可留空) "ownerid":"", //文章发布者ID(可留空) "metadata":"", //文章其他信息(可留空) "comments":[ { "cmtid":"358", //评论唯一ID "ctime":1401327899094, //评论时间 "content":"2013年8月1日18:36:29 O(∩_∩)O~", //评论内容 "replyid":"0", //回复的评论ID,没有为0 "user":{ "userid":"1", //发布者ID "nickname":"admin", //发布者昵称 "usericon":"", //发布者头像(留空使用默认头像) "userurl":"", //发布者主页地址(可留空) "usermetadata":{ //其它用户相关信息,例如性别,头衔等数据 "area": "北京市", "gender": "1", "kk": "", "level": 1 } }, "ip":"127.0.0.1", //发布ip "useragent":"Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0", //浏览器信息 "channeltype":"1", //1为评论框直接发表的评论,2为第三方回流的评论 "from":"", //评论来源 "spcount":"", //评论被顶次数 "opcount":"", //评论被踩次数 "attachment":[ //附件列表 { "type":1, //1为图片、2为语音、3为视频 "desc":"", //描述, "url":"http://img.sohu.itc/xxxx" //附件地址 } ] } ] }
你可以参照以上字段进行下一步业务的处理!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)