在我的codeigniter脚本日志中,我看到了这个错误:
ERROR - 2018-02-12 03:54:11 - >严重性:警告 - > array_values()期望参数1为数组,给定对象/home/webhouse/public_html/app/helpers/instagram_helper.php 169
instagram_helper.php第169行:
return array_values($feeds);
这是instagram_helper.php php代码:
function instacurl(){
if(FX == 1){
return false;
}else{
return true;
}
}
function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function removeFeedVideo($result){
if(!empty($result)){
foreach ($result as $key => $row) {
if($row->media_type != 1){
unset($result[$key]);
continue;
}
}
return array_values($result);
}
}
function removeFeedPrivate($result){
if(!empty($result)){
foreach ($result as $key => $row) {
if(isset($row->user) && $row->user->is_private == 1){
unset($result[$key]);
continue;
}
}
return array_values($result);
}
}
function removePrivateUser($result){
if(!empty($result)){
foreach ($result as $key => $row) {
if($row->is_private == 1){
unset($result[$key]);
continue;
}
}
return array_values($result);
}
}
function removePrivateUserComments($result){
if(!empty($result)){
foreach ($result as $key => $row) {
if($row->user->is_private == 1){
unset($result[$key]);
continue;
}
}
return array_values($result);
}
}
function removeFeedBlackLists($feeds,$bl_tags,$bl_usernames,$bl_keywords){
// pr(count($feeds),0);
$feeds=json_encode($feeds);
$feeds=json_decode($feeds);
// pr($feeds,1);
foreach ($feeds as $key => $row) {
$check_tags=false;
$check_usernames=false;
$check_keywords=false;
if(!empty($row->preview_comments)&&is_array($row->preview_comments)) {
if(!empty($row->preview_comments[0])){
$preview_comments_1 = $row->preview_comments[0];
$preview_comments_1 = strtolower($preview_comments_1->text);
if(!empty($row->preview_comments[1])){
$preview_comments_2 = $row->preview_comments[1];
$preview_comments_2 = strtolower($preview_comments_2->text);
$preview_comments = $preview_comments_1.' '.$preview_comments_2;
}
}
}
$caption_text="";
if(!empty($row->caption->text)){
$caption_text = strtolower($row->caption->text);
// pr($caption_text,0);
}
if(isset($preview_comments)){
$caption_text.=' '.$preview_comments;
$caption_hashtags=getDataFromString($caption_text,$target="hashtags");
}
if (!empty($row->user)) {
$blist_usernames = $row->user;
$blist_usernames = strtolower($blist_usernames->username);
}
if(!empty($caption_text)){
$caption_usernames=getDataFromString($caption_text,$target="usernames");
$caption_usernames[]="@".$blist_usernames;
$caption_usernames = array_count_values($caption_usernames);
$caption_usernames = array_keys($caption_usernames);
}
if (!empty($bl_tags)&&is_array($bl_tags)&&!empty($caption_hashtags)&&is_array($caption_hashtags)) {
if ($check_usernames==false&&$check_keywords==false) {
foreach ($bl_tags as $pattern) {
$pattern = trim($pattern);
$pattern = "#".$pattern;
foreach ($caption_hashtags as $val) {
if ($pattern==$val) {
// echo "<b style='color:blue;'>Khớp bl_tags: $pattern</b><br>";
// echo "<i style='color:red;'>text</i>";
// pr($caption_text,0);
// echo "<i style='color:red;'>comment</i>";
// echo "<b style='color:red;'>Ton tai TAGS</b>";
$check_tags=true;
break;
}
}
if ($check_tags) {
break;
}
}
}
}
// usernames
if(!empty($bl_usernames)&&is_array($bl_usernames)&&!empty($caption_usernames)&&is_array($caption_usernames)){
if ($check_tags==false&&$check_keywords==false) {
foreach ($bl_usernames as $pattern) {
$pattern = trim($pattern);
$pattern = "@".$pattern;
foreach ($caption_usernames as $val) {
if ($pattern==$val) {
$check_usernames=true;
break;
}
}
if ($check_usernames) {
break;
}
}
}
}
// keywords
if(!empty($bl_keywords)&&is_array($bl_keywords)&&is_string($caption_text)){
if ($check_tags==false&&$check_usernames==false) {
$re = '/\b(?:' . join('|', array_map(function($keyword) {return preg_quote($keyword, '/'); }, $bl_keywords)) . ')\b/i';
if (preg_match_all($re, $caption_text, $matches)>0) {
$check_keywords=true;
}
}
}
if ($check_tags==true||$check_usernames==true||$check_keywords==true) {
unset($feeds[$key]);
}
}
//pr(count($feeds),0);
return array_values($feeds);
}
任何想法?