undefined index
当我尝试screen_name
从 Twitter API 1.1 用户时间线访问键值对时出现以下错误https://api.twitter.com/1.1/statuses/user_timeline.json
遇到 PHP 错误
严重性:通知
消息:未定义索引:screen_name
文件名:控制器/search.php
行号:98
当我 print_r(); 时我可以看到 screen_name 键 存储结果的关联数组:
Array ( [0] => Array ( [created_at] => Tue Mar 19 21:55:31 +0000 2013 [id] => 3.141330578148E+17 [id_str] => 314133057814798336 [text] => 赢得 4 件装3 月 26 日至 31 日通过@604Now 获得@VanAutoShow 门票 - http://t.co/2G0pyNNgLl RT 进入![来源] => Mac 版 Twitter [截断] => [in_reply_to_status_id] => [in_reply_to_status_id_str] => [in_reply_to_user_id] => [in_reply_to_user_id_str] => [in_reply_to_screen_name] => [user] => 数组([id] => 128700677 [id_str] => 128700677 [name] => Bernard Poon [screen_name] => StackOverflow [location] => 温哥华,不列颠哥伦比亚省 [描述] => 称温哥华为家的 Code Monkey。喜欢 Apple 产品和新手摄影师。[url] => http://t.co/wlxhr5tpes[实体] => 数组 ( [url] => 数组 ( [urls] => 数组 ( [0] => 数组 ( [url] => http://t.co/wlxhr5tpes [expanded_url] => http:// /ceciliaandbernard.com [display_url] => ceciliaandbernard.com [indices] => 数组 ( [0] => 0 1 => 22 ) ) ) ) [description] => 数组 ( [urls] => 数组 ( ) ) ) [受保护] => [followers_count] => 157 [friends_count] => 13 [listed_count] => 4 [created_at] => Thu Apr 01 23:16:57 +0000 2010 [favourites_count] => 0 [utc_offset] =>
如果我使用Users Show TWitter API 1.1 资源且没有错误,我可以访问 screen_name 键值对。但是,当我使用User Timeline Twitter API 1.1 资源时,我收到了上述undefined index
错误。下面是我用来访问这两种资源的函数的代码片段,结果不同:
function does_user_exist($r)
{
// convert to associative array
// inorder to search for keys
$a = json_decode($r, true);
echo "Screen Name: " . $a['screen_name'];
}
任何帮助将不胜感激。提前致谢。