danio1024/ip-user-location

The Extension is working properly but the response is not an array when trying to convert the json data to array.

Here is what I did:


 $ipInfo = new ipInfo ('Mykey', 'json');

                    try {

                    Yii::$app->session['Countryinfo'] = json_decode($ipInfo->getCountry('154.70.157.3'));


}catch(Exception $e)

                      {

                       Yii::$app->session['Countryinfo'] = null;

                     }

 if(Yii::$app->session['Countryinfo'] && count(Yii::$app->session['Countryinfo']['countryCode'])==2){

                          echo 'ok';

}

I am getting an error saying:

And if I dump :


var_dump(json_decode($ipInfo->getCountry('170.70.120.3')));

I get :

Wich shows the value is an object not an array.

I really don’t know what to do.

I’ve tried everything to understand the problem but I don’t see what or how to access those information.