Q:

get_class() expects parameter 1 to be object, string given when using bitly-url-shortener

I wanted to use bitly-url-shortener (http://www.yiiframework.com/extension/bitly-url-shortener/) to shorten my url. The code  that I am using is below,
<?php Yii::app()->bitly->shorten('http://www.betaworks.com')->getResponseData(); ?>

It give me this error,
 get_class() expects parameter 1 to be object, string given

D:\_App\buddyshop\protected\extensions\bitly\VGBitly.php(578)

566      */
567     public function getErrorMessage()
568     {
569         return $this->errorMessage;
570     }
571     
572     /**
573      * @return array - Convert a SimpleXML object to an array so we
574      * Could safely store it in the cache and retrieve it when needed.
575      */
576     protected function simplexml2array($xml) 
577     {
578         if (get_class($xml) == 'SimpleXMLElement') 
579         {
580             $attributes = $xml->attributes();
581             foreach($attributes as $k=>$v) 
582             {
583                 if ($v) $a[$k] = (string) $v;
584             }
585             $x = $xml;
586             $xml = get_object_vars($xml);
587         }
588         if (is_array($xml)) 
589         {
590             if (count($xml) == 0) return (string) $x; // for CDATA

the error is indicated on line 578.
Any help would be greatly appreciated. Thanks!

A:

As you have contacted author of code hopefully you will get better solution from them but meanwhile you can place below to make it work:
replace :
if (get_class($xml) == 'SimpleXMLElement') 

with 
if (is_object($xml) && get_class($xml) == 'SimpleXMLElement') 

