This is a Drupal-related development mailing list, not a general support list. Please, use the forum for this kind of requests: http://drupal.org/forum Thanks. On Thu, Sep 15, 2011 at 11:11 AM, Pooya <pooya.source@gmail.com> wrote:
I just wrote a module to send a report of all our online clients to us(server) every time cron runs. In this situation I made both server and client module in one drupal installation, to develop and test. I faced a weired problem so here's my code(just lines u need to see).
this is a hook_menu for 'itaco_remote' which is the callback of server module. Then 'itacocms_report' item which I made to call a function and test reporting, this one will be in client module and will be removed, so I call it in cron. <?php function itacocms_menu() { $items['itaco_remote'] = array( 'page callback' => 'itacocms_itaco_xml', 'access arguments' => array('access content'), 'page arguments' => array(1,2,3,4,5,6,7,8,9,10,11), 'type' => MENU_CALLBACK, ); $items['itacocms_report'] = array( 'page callback' => 'itacocms_itaco_report', 'access arguments' => array('access content'), ); return $items; } ?>
this function is called when 'itaco_remote' page is requested, calling with arguments. <?php function itacocms_itaco_xml($name='name', $url='url', $key='01', $phone='01', $email='email', $date='date', $major='01', $build='01', $address='address', $reseller='reseller', $report_time='01010101'){ $result=db_query("INSERT INTO {itacocms_report} (name, url, key, phone, email, date, major, build, address, reseller, report_time) VALUES ('%s','%s', %d, %d,'%s','%s', %d, %d,'%s','%s', %d)", $name, $url, $key, $phone, $email, $date, $major, $build, $address, $reseller, $report_time); } ?>
This one is where I used 'drupal_http_request()' and send the data I need, to above function using GET method. <?php function itacocms_itaco_report(){ global $base_url; $request_url = 'http://localhost/poosheshrah.com/itaco_remote'. '/'.urlencode(itacocms_customer_info(name)). '/'.urlencode($base_url). '/'.urlencode(itacocms_customer_info(product_id)). '/'.urlencode(itacocms_customer_info(phone)). '/'.urlencode(itacocms_customer_info(email)). '/'.urlencode(itacocms_customer_info(date)). '/'.urlencode(itacocms_customer_info(major)). '/'.urlencode(itacocms_customer_info(build)). '/'.urlencode(itacocms_customer_info(address)). '/'.urlencode(itacocms_customer_info(reseller)). '/'.'010101';
// Send the request. $result = drupal_http_request($request_url); } ?>
Problem here is when I open 'example.com/itacocms_report' and it sends the request to 'itaco_remote' db_query doesn't work at all and nothing's inserted in database. Is there something wrong with my drupal_http_request() or db_query()?
I tried to debug this and using print and devel module but couldn't find the problem. also made a topic here http://drupal.org/node/1280106
-- Paolo Mainardi CTO Twinbit ILDN: http://www.ildn.net Blog: http://www.paolomainardi.com -- Please consider the environment before printing this email --