Hello Developers! I am getting this strange error! I get the follows of a channel using /channels/:channel/follows, and I can get two of the parameters perfectly (_links, _total). The error I get is when I try to get the follows parameter, it does not return a array. Even if _total is 36567, the follows parameter returns not a array of followers. Here is how I call to the api:
function get_follows($channel){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->base_url . "channels/" . $channel . "/follows");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
$response = json_decode($output, true);
curl_close($ch);
if (isset($response['error'])) {
echo 'Unauthorized | You have used the wrong Access Token or don\'t have the correct scope';
} else {
require_once(dirname(__FILE__) . '/channel/Follows.php');
$follows = new Follows($response['_total'], $response['_links'], $response['follows']);
return $follows;
}
}
My follows class is the following:
<?php
class Follows {
public $_total, $next_link, $self_link, $follows;
public function __construct($_total, $_links, $follows){
$this->_total = $_total;
$this->next_link = $_links['next'];
$this->self_link = $_links['self'];
if (is_array($follows)) {
$follow_list = array();
foreach ($follows as $value) {
require_once(dirname(__FILE__) . '/Follow.php');
array_push($follow_list, new Follow($value['created_at'], $value['_links'], $value['notifications'], $value['user']));
}
$this->$follows = $follow_list;
} else {
$this->$follows = $follows;
}
}
}
This is weird because the same exact code works for other things in the api.
Thanks in advance,
Avery.