If I run cron I get the following error

Fatal error: Call to undefined function curl_init() in C:\xampp\htdocs\sites\all\modules\weblinks\contribs\pralexa\pralexa.module on line 312

I recently updated to 2.0-rc2 (with the former files of the module removed), then to the latest dev of May 31 and also ran update.php. I also just activated the show ranking information.

What can I do?

Comments

nancydru’s picture

Status: Active » Postponed (maintainer needs more info)

The simplest thing at the moment is to add the "php_curl" extension to your Apache set up (and restart it).

I think we are going to have to add a requirements check for Pralexa. (see something like #334545: Call to undefined function curl_init()).

nancydru’s picture

Hmm, I also found #219873-3: PHP Fatal error: Call to undefined function curl_init(), which looks workable since we already use that function.

chia’s picture

Just uncomment the line inside php.ini:
;extension=php_curl.dll
just make sure that curl appear as enabled in phpinfo
just restart your Apache
And i think it should work.

Correct me if i didnt get your Question.

nancydru’s picture

@jasonleon: Thanks for the answer. I'm wondering if switching to drupal_http_request (in the second link above) might be a better solution.

chia’s picture

well i just read the drupal_http_request function.
I am pretty sure it will work.
Well Socket connection used in drupal_http_request is a better way so switching might be a good idea.

nancydru’s picture

For example:

  $url = 'http://nanwich.info';

  $request_url = "http://data.alexa.com/data?cli=10&dat=snbamz&url=". $url;
  $answer = drupal_http_request($request_url);
  if ($answer->code == '200') {
    $answer = simplexml_load_string($answer->data);
    drupal_set_message('I think the Alexa rank is: '. $answer->SD->POPULARITY['TEXT']);
  }
  else {
    watchdog('Pralexa', t('Bad Alexa response: @code'), array('@code' => $answer->code), WATCHDOG-ERROR);
  }

  $query ="http://toolbarqueries.google.com/search?client=navclient-auto&ch=". _pralexa_checkhash(_pralexa_hashurl($url)) ."&features=Rank&q=info:". $url ."&num=100&filter=0";
  $answer = drupal_http_request($query);
  if ($answer->code == '200') {
    $pieces = explode(':', $answer->data);
    drupal_set_message('I think the Google rank is: '. $pieces[2]);
  }
  else {
    watchdog('Pralexa', t('Bad Google response: @code'), array('@code' => $answer->code), WATCHDOG-ERROR);
  }
nancydru’s picture

SimpleXML is enabled by default, but I wonder if a hook_requirements would still be a good idea?

Duh: http://drupal.org/project/simplexml

chia’s picture

Hey i have seen the changes to the module.
Well, was there any problem in parsing xml through simplexml_load_file function ?
I thought this was a better way to do that.

nancydru’s picture

I tried the above code (with the simplexml) as a php page and it worked. Now I just need to put them into the module when I have time. I'm just not sure whether or not to require the module I pointed to or to reproduce that code in Web Links or just not worry about it.

nancydru’s picture

Status: Postponed (maintainer needs more info) » Fixed

committed to 6.x-2.x-dev

nancydru’s picture

Status: Fixed » Closed (fixed)

Included in 6.x-2.0-rc3.

adnanawan’s picture

i installed the apachi php server, i findout file php.ini i changed and also deleted but i not got changing in error curl.ini() and drupal_http_request not sucess can u sure its running in other server what i must to reset
please if u have any solution then tel me what shuld i do for that critical mattar ,,, i want this answer to solve ,
i restarted apachi so not changing something , error is error not sucesss tel me curlini problem , anser reply me