It's possible your request URL isn't working since it references localhost.<br clear="all"><div><br></div><font color="#333333">Carl Wiedemann</font><div><div><font color="#333333">Website design and development consulting</font></div>
<div><font color="#333333"><a href="mailto:carl.wiedemann@gmail.com" target="_blank">carl.wiedemann@gmail.com</a> | skype: c4rlww</font></div></div><br>
<br><br><div class="gmail_quote">On Thu, Sep 15, 2011 at 3:11 AM, Pooya <span dir="ltr"><<a href="mailto:pooya.source@gmail.com">pooya.source@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<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" target="_blank">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" target="_blank">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" target="_blank">http://drupal.org/node/1280106</a><br></div>
</blockquote></div><br>