use of curl to hit drupal url to get some data from external php file
rushali - November 19, 2008 - 09:12
Hi,
I am newbie to drupal. I have some questions regarding use of curl.
I want to get some drupal data from my drupal module in external php. Can we use echo or print_r statement in drupal module?
For example: I am saving some record in DB using curl and want to get id of last inserted record for further functionality.
How can I achieve that? I have used curl for this, but I am a bit confused can we use echo statement in module or not. It also require access permissions. How can I handle this.
Thanks
Rushali

print 'anything';
You can print anything from within a Drupal module. There are functions to format the output via a theme and to translate the output for different languages. You probably want the output unformatted.
You mention Curl. Are you reading the data using a Web services approach? Are you using Ajax? Jason? XML RPC? Do you have site A using Curl to read data from site B? If both A and B are Drupal, you can use Web services to talk between the two. Describe your setup in more detail.
petermoulding.com/web_architect
Hi peterx, Thanks for
Hi peterx,
Thanks for reply.
In my case A and B both are not Drupal. Site A is drupal and B is also part of my module but it is some third party code, in which it has its own php classes and functions. Now I want some Drupal data in site B, which requires token module. To get exact data I need to hit drupal url which return me that data either in string format or array. I took the curl to achieve my object. But I am not sure, is it a correct way to echo that data in drupal module. If you have any other suggestion to achieve this, please suggest.
Thanks for help again.
Rushali
Drupal XMLRPC to non Drupal site
Site A is Drupal. Site B is not Drupal. Site B wants to read data from site A.
I did the reverse: Site B is Drupal. Site A is not Drupal. Site B reads data from site A. I describe it in:
Drupal XMLRPC to non Drupal site: http://drupal.org/node/324938
You might be able to use the reverse and use XMLRPC through the Drupal functions. XMLRPC may take longer to learn but gives you far more options and flexibility when you have to add extra data requests. You also get the advantage of compatibility when you convert site B to Drupal.
Why is Drupal code good? It is tested with lots of sites. If you do not want to use the Drupal functions, read their code. You will probably find they use file functions instead of Curl. Curl is really only needed when you want complicated stuff such as monitoring ports.
petermoulding.com/web_architect