Fixing a Code with the API of twitch

Firstly, I apologies if this is the wrong category to post this;

I had been making use of a code that helped me to embeds my twitch streams from my profile on my website.
Recently I noticed it got broken and have tried various methods to patch this up, while reading various documentation in respect to the API

In other for me to fetch the username on twitch i used the " echo $this->" within the code and with the whole code all i did was to create a profile field and simply specify the twitch user name.

This method takes it a step further than just embedding twitch
Reasons because: all it takes is for the user to add the twitch name and this fetches the stream page; and is good for ideas of multi authors on a site.
I would love if someone could take a look and correct me on the path that is wrong I took, as i had racked here and there for solutions.

Below is the Code;

//Boundmix Profilage - to promote twitch users
/* ADDing twitch from bp profile*/

 $channelsApi = 'https://glass.twitch.tv/console';
 $channelName = 'null';
 $clientId = 'kr48dgy7mckk8vg3aj0tgezou1okuw';
 $ch = curl_init();
 
 curl_setopt_array($ch, array(
    CURLOPT_HTTPHEADER => array(
       'Client-ID: ' . $clientId
    ),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_URL => $channelsApi . $channelName
 ));
 
 $response = curl_exec($ch);
 curl_close($ch);


/* ADDing twitch from bp profile*/

/* ADDing twitch from bp profile*/

// Add's Twitch Channel To Boundmix Profiles
if(!class_exists('BP_Twitch_Tab')):
class BP_Twitch_Tab {
    public $tab_name = 'Twitch TV';
    public $content_title = 'Twitch TV Channel';
    public $url_slug = 'twitchtv';
    public $subnav_slug = 'twitchtv';
    public $tab_position = 40;
    public $show_chat = true;

    // channel name will be grabbed from buddypress field $field_name
    public $channelName = null;
    public $field_name = 'Twitch Channel';
    public function __construct () {
        add_action('bp_setup_nav', array($this, 'profile_tab'));
    }

    // add profile tab
    public function profile_tab() {
        global $bp;
        // get channel name
        $this->channelName = bp_get_profile_field_data('field=' . $this->field_name . '&user_id=' . bp_loggedin_user_id());
        if($this->channelName) {
            bp_core_new_nav_item( array(
                'parent_url'           => bp_loggedin_user_domain() . '/' . $this->url_slug . '/',
                'slug'                 => $this->url_slug,
                'default_subnav_slug'  => $this->subnav_slug,
                'parent_slug'          => $bp->profile->slug,
                'name'                 => $this->tab_name,
                'position'             => $this->tab_position,
                'screen_function'      => array($this, 'screen_function')
            ) );
        }
    }

    // call actions on profile screen
    public function screen_function() {
        add_action( 'bp_template_title', array($this, 'template_title') );
        add_action( 'bp_template_content', array($this, 'template_content') );
        bp_core_load_template( 'buddypress/members/single/plugins' );
    }

    // add content title
    public function template_title() {
        echo $this->content_title;
    }

    // show iframe
    public function template_content() {
        ?> <iframe src="https://player.twitch.tv/?channel=<?php echo $this->channelName?>" frameborder="0" scrolling="no" height="500" width="100%"></iframe> 
        <?php
        // show chat
        if ($this->show_chat) {
            ?> <iframe frameborder="0" scrolling="no" class="chat_embed" src="https://www.twitch.tv/chat/embed?channel=<?php echo $this->channelName;?>" height="500" width="100%"></iframe> <?php
        }
    }
}
endif;
new BP_Twitch_Tab;

Future Plans: Although, In the future: I plan to add Authentications where the login to site function would fetch the user name if the user signs to the site through twitch
Hope to find someone that can shed light on this.
Thank you for having this wonderful community Twitch.

So looks like you are using Wordpress with the plugin buddypress and having an issue with the buddypress template for the profile field not showing the right information?

Yes kind of but my issue is why it keeps fetching array as the twitch user-name when i place a separate username .

I do not mind sharing the link to my website where I use it, for better understanding;

https://buddypress.org/support/topic/shortcode-returns-string-array/

This is a WordPress problem not a TwitchAPI problem.