get_class() 期望参数 1 为对象,使用 bitly-url-shortener 时给出的字符串
get_class() expects parameter 1 to be object, string given when using bitly-url-shortener
我想使用 bitly-url-shortener (http://www.yiiframework.com/extension/bitly-url-shortener/) 来缩短我的 url。我正在使用的代码如下,
<?php Yii::app()->bitly->shorten('http://www.betaworks.com')->getResponseData(); ?>
它给我这个错误,
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
第 578 行指出了错误。
如有任何帮助,我们将不胜感激。谢谢!
因为您已经联系了代码作者,希望您能从他们那里得到更好的解决方案,但同时您可以在下面放置使其工作:
替换:
if (get_class($xml) == 'SimpleXMLElement')
和
if (is_object($xml) && get_class($xml) == 'SimpleXMLElement')
我想使用 bitly-url-shortener (http://www.yiiframework.com/extension/bitly-url-shortener/) 来缩短我的 url。我正在使用的代码如下,
<?php Yii::app()->bitly->shorten('http://www.betaworks.com')->getResponseData(); ?>
它给我这个错误,
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
第 578 行指出了错误。
如有任何帮助,我们将不胜感激。谢谢!
因为您已经联系了代码作者,希望您能从他们那里得到更好的解决方案,但同时您可以在下面放置使其工作:
替换:
if (get_class($xml) == 'SimpleXMLElement')
和
if (is_object($xml) && get_class($xml) == 'SimpleXMLElement')