JSON问题&;PHP。试图显示推文:代码知道推文的数量,但显示为';空';

JSON问题&;PHP。试图显示推文:代码知道推文的数量,但显示为';空';,json,twitter,Json,Twitter,我正在使用(与tmhOAuth.php一起使用)。 我填写了Twitter API中的密钥并上传了cacert.pem 我编写了以下代码 <?php $_tweet = array(); $_i = 0; $_mycurl = curl_init(); curl_setopt ($_mycurl, CURLOPT_HEADER, 0); curl_setopt ($_mycurl, CURLOPT_RETURNTRANSFER, 1); $_url = "http://www.jo

我正在使用(与tmhOAuth.php一起使用)。 我填写了Twitter API中的密钥并上传了cacert.pem

我编写了以下代码

<?php

$_tweet = array();

$_i = 0;
$_mycurl = curl_init();

curl_setopt ($_mycurl, CURLOPT_HEADER, 0);
curl_setopt ($_mycurl, CURLOPT_RETURNTRANSFER, 1); 
$_url = "http://www.joycot.com/test/plugins/tweet/tweets_json.php?screen_name=USERNAME"; 
curl_setopt ($_mycurl, CURLOPT_URL, $_url);
$_web_response =  curl_exec($_mycurl); 


$_array = json_decode($_web_response, true);
if ($_web_response) {
  foreach($_array as $_value) {
    $_tweet[$_i] = $_value->text;
    $_i++;
  }
}

$_data['tweets'] = $_tweet;

echo json_encode($_data);

?>

它显示了正确数量的tweet,但我找不到显示JSON数据的方法

{“tweets”:[null,null,null…]}


我做错了什么?就在几天前,我开始学习json。

你几乎说对了。您只需更换线路:

$_array = json_decode($_web_response, true);
作者:

因为如果第二个参数为true,则将使用不同类型的数组给出结果:

$_array = json_decode($_web_response);