## 好文收藏查看接口
### 1.调试接口
+++
get:http://www.dakaifa.net/index.php?g=App&m=My&a=article_collect
*string:uid=117#用户id
<<<
success
[
{
"id": "36",
"uid": "117",
"title": "警惕腰肌劳损!送给久坐族的防治腰疼秘籍",
"url": null,
"description": null,
"table": null,
"object_id": "137",
"createtime": "2016-07-30",
"smeta": "http://dakaifa.net/data/upload/20160708/577f0fa3981c6.jpg",
"tid": "136",
"post_like": "3",
"post_hits": "48"
},
{
"id": "40",
"uid": "117",
"title": "色盲眼中的世界是怎样的?",
"url": null,
"description": null,
"table": null,
"object_id": "117",
"createtime": "2016-08-07",
"smeta": "http://dakaifa.net/data/upload/20160706/577cb5419ce12.png",
"tid": "115",
"post_like": "3",
"post_hits": "52"
}
]
Method
<<<
error
+++
### 2.接口代码
```
public function article_collect(){
$uid=$_GET['uid'];
$user_favorites_model=M("UserFavorites");
$favorites=$user_favorites_model->where(array('uid'=>$uid))->select();
$rela_model=M('Term_relationships');
foreach ($favorites as &$value) {
// posts表中文章的id
$pid=$value['object_id'];
// 查询Term_relationships表中的tid
$row=$rela_model->where(array('object_id'=>$pid))->select();
$tid=$row[0]['tid'];
// 查询文章信息
$article=sp_sql_post($tid,'field:smeta,post_like,post_hits,tid;');
$article['smeta']=json_decode($article['smeta'],true);
$article['smeta']="http://".$_SERVER['SERVER_NAME']."/data/upload/".$article['smeta']['thumb'];
// 赋值到用户收藏表中
$value['smeta']= $article['smeta'];
$value['tid']=$article['tid'];
$value['post_like']=$article['post_like'];
$value['post_hits']=$article['post_hits'];
$value['createtime']=date('Y-m-d', $value['createtime']);
}
echo json_encode($favorites);
}
```