我想在facebook帖子上添加评论..来自facebook API
添加评论的功能是
public function fill($json)
{
if(isset($json['data']))
{
$json = $json['data'];
}
foreach($json as $k => $v ) $this->{$k} = $v;
}
我将数据以json格式传递为
{"data":{"id":"153870348034313_347443752010304","message":"test comment"}}
但回复是:Invalid argument supplied for foreach()
答案 0 :(得分:1)
您没有解码JSON
:
public function fill($json)
{
$json = json_decode($json);
if(isset($json->data))
{
$json = $json->data;
}
foreach($json as $k => $v ) $this->{$k} = $v;
}