<div dir="ltr">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).<br>
<br>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.<br>
<?php<br><b>function itacocms_menu() {<br> $items['itaco_remote'] = array(<br> 'page callback' => 'itacocms_itaco_xml',<br> 'access arguments' => array('access content'),<br>
'page arguments' => array(1,2,3,4,5,6,7,8,9,10,11),<br> 'type' => MENU_CALLBACK,<br> );<br> $items['itacocms_report'] = array(<br> 'page callback' => 'itacocms_itaco_report',<br>
'access arguments' => array('access content'),<br> );<br> return $items;<br>}</b><br>?><br><br><br>this function is called when 'itaco_remote' page is requested, calling with arguments.<br>
<?php<br><b>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'){<br>
$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);<br>
}</b><br>?><br><br>This one is where I used 'drupal_http_request()' and send the data I need, to above function using GET method.<br><?php<br><b>function itacocms_itaco_report(){<br> global $base_url;<br> $request_url = '<a href="http://localhost/poosheshrah.com/itaco_remote">http://localhost/poosheshrah.com/itaco_remote</a>'.<br>
'/'.urlencode(itacocms_customer_info(name)).<br> '/'.urlencode($base_url).<br> '/'.urlencode(itacocms_customer_info(product_id)).<br> '/'.urlencode(itacocms_customer_info(phone)).<br> '/'.urlencode(itacocms_customer_info(email)).<br>
'/'.urlencode(itacocms_customer_info(date)).<br> '/'.urlencode(itacocms_customer_info(major)).<br> '/'.urlencode(itacocms_customer_info(build)).<br> '/'.urlencode(itacocms_customer_info(address)).<br>
'/'.urlencode(itacocms_customer_info(reseller)).<br> '/'.'010101';<br> <br>// Send the request.<br> $result = drupal_http_request($request_url);<br>}</b><br>?><br><br><br>Problem here is when I open '<a href="http://example.com/itacocms_report">example.com/itacocms_report</a>' 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()?<br>
<br>I tried to debug this and using print and devel module but couldn't find the problem.<br>also made a topic here <a href="http://drupal.org/node/1280106">http://drupal.org/node/1280106</a><br></div>