如果你能帮助我访问这个Json的“文本”,我将不胜感激。我试过但我不能,我留下了PHP代码。
php中用于访问和提取文本的代码:
$url = $url_to;
$array = array();
while(1) {
$file = fopen("links.txt", "a");
$json = json_decode(file_get_contents($url));
$filter_array = array_filter($json->params->tag->to_posts->bordes->node->to_caption->bordes->node);
foreach($filter_array as $object_return){
echo $object_return->code.'</br>';
fwrite($file, $object_return->code);
fwrite($file,"\n");
}
fclose($file);
这是json数据:
{
"params":{
"tag":{
"name":"examples",
"is_top_media_only":false,
"media":{ },
"to_posts":{
"bordes":[
{
"node":{
"id":"168970",
"to_caption":{
"bordes":[
{
"node":{
"text":"Yes, its very strong..."
}
}
]
},
"shortcode":"BBB1",
"edge_media_to_comment":{
"count":2
},
"taken_at_timestamp":15156,
"dimensions":{
"height":1078,
"width":1080
},
"display_url":"http://example.com",
"edge_liked_by":{
"count":73
},
"owner":{
"id":"40237"
},
"thumbnail_src":"http://example.com",
"thumbnail_resources":[
{
"src":"http://example.com",
"config_width":150,
"config_height":150
},
{
"src":"http://example.com",
"config_width":240,
"config_height":240
},
{
"src":"http://example.com",
"config_width":320,
"config_height":320
},
{
"src":"http://example.com",
"config_width":480,
"config_height":480
},
{
"src":"http://example.com",
"config_width":640,
"config_height":640
}
],
"is_video":false
}
},
{
"node":{
"id":"16738",
"to_caption":{
"bordes":[
{
"node":{
"text":"Hahaha its cool"
}
}
]
},
我需要访问json的所有文本,因为还有更多,但我留下了。 正如您所看到的,我试图提取它,但它总是会生成类型为sdtClass的错误。 谢谢你!