调用未定义的函数

调用未定义的函数

本文介绍了调用未定义的函数:simplexml_load_string()在cron文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cron文件实现facebook计数功能。

  for($ i = 0; $ i< 3; $ i ++){
$ source_url = $ cars [$ i];
$ rest_url =http://api.facebook.com/restserver.php?method=links.getStats&urls=\".urlencode($source_url);
$ curl = curl_init();
curl_setopt($ curl,CURLOPT_URL,$ rest_url);
curl_setopt($ curl,CURLOPT_RETURNTRANSFER,1);
$ content = curl_exec($ curl);
curl_close($ curl);
$ message = stripslashes($ content);
$ xml_record = simplexml_load_string($ message);
$ fb_like_count = $ xml_record-> link_stat-> like_count;
echo。$ fb_like_count;
mail([email protected],hi。$ fb_like_count,$ message);
}

但是我正在调用未定义的调用函数错误。

解决方案

对于PHP 7和Ubuntu 14.04,过程如下。由于PHP 7不在官方Ubuntu PPAs,你可能通过OndřejSurý的PPA(sudo add-apt-repository ppa:ondrej / php)安装它。转到/etc/php/7.0/fpm并编辑php.ini,取消注释到以下行:

  extension = php_xmlrpc.dll 

然后只需安装php7.0-xml:

  sudo apt-get install php7.0-xml 

重新启动PHP:

  sudo服务php7.0-fpm restart 
pre>

如果您使用的是包含PHP 7的更高版本的Ubuntu版本,该过程很可能也是一样。


I am implementing facebook count function using cron file. In which cron runs every 10 minutes and counts the total likes of a page.

for($i=0;$i<3;$i++){
    $source_url =$cars[$i];
    $rest_url = "http://api.facebook.com/restserver.php?method=links.getStats&urls=".urlencode($source_url);
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL,$rest_url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $content = curl_exec($curl);
    curl_close($curl);
    $message=stripslashes($content);
    $xml_record = simplexml_load_string($message);
    $fb_like_count = $xml_record->link_stat->like_count;
    echo "".$fb_like_count;
    mail("[email protected]","hi".$fb_like_count,$message);
}

But I am geting undefined call function error.

解决方案

For PHP 7 and Ubuntu 14.04 the procedure is follows. Since PHP 7 is not in the official Ubuntu PPAs you likely installed it through Ondřej Surý's PPA (sudo add-apt-repository ppa:ondrej/php). Go to /etc/php/7.0/fpm and edit php.ini, uncomment to following line:

extension=php_xmlrpc.dll

Then simply install php7.0-xml:

sudo apt-get install php7.0-xml

And restart PHP:

sudo service php7.0-fpm restart

If you are on a later Ubuntu version where PHP 7 is included, the procedure is most likely the same as well.

这篇关于调用未定义的函数:simplexml_load_string()在cron文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 14:30