title: How to use CURL to send data for Wordpress
body: <p>I would like to send data from one WP site to an other. 
  I have two plugins the sender ad the reciver. 
  In the sender side I used the init hook </p>
  
  <pre><code>add_action('init', array($this, 'say_hello') );
  
  ....
  
  public function say_hello() {
  $data = get_plugin_data( $this-&gt;pDIR.'/plugin.php', $markup = false, $translate = false );
  
  $url = $_SERVER['HTTP_HOST'].'/wp-admin/admin-ajax.php';
  
  $fields = array(
            'action' =&gt; 'Hello_ajax',
            'zpm_hello' =&gt; '1',
            'zpm_plugin_version' =&gt; $data['Version'],
            'zpm_host' =&gt; $_SERVER['HTTP_HOST']
  );
  
  foreach($fields as $key=&gt;$value) { 
          $fields_string .= $key.'='.$value.'&amp;'; 
  }
  rtrim($fields_string, '&amp;');
  //open connection
  $ch = curl_init();
  //set the url, number of POST vars, POST data
  curl_setopt($ch,CURLOPT_URL, $url);
  curl_setopt($ch,CURLOPT_POST, count($fields));
  curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
  //execute post
  $result = curl_exec($ch);
  var_dump($result);
  //close connection
  curl_close($ch);
  
  }
  </code></pre>
  
  <p>The variables are fine the url is correct I printed out. 
  On the reciver side I registered the admin ajax </p>
  
  <pre><code>add_action('wp_ajax_Hello_ajax', array($this, 'zpm_api_hello'));
  add_action('wp_ajax_nopriv_Hello_ajax', array($this, 'zpm_api_hello'));
  
  public function zpm_api_hello() {
      $response['success'] = false;
      $response['response'] = "";
      $error = false;
  
      $hello          = $_POST['zpm_hello'];
      $plugin_version = $_POST['zpm_plugin_version'];
      $plugin_host    = $_POST['zpm_host'];
  
      if(!isset($hello)) {
          $error = true;
          $response['response'] .= "Ello &gt;&gt; Auth ERROR - CODE - 01 ";
      } 
  
      if(!isset($plugin_version)) {
          $error = true;
          $response['response'] .= "Ello &gt;&gt; Plugin Version error - CODE - 02 ";
      }
  
      if(!isset($plugin_host)) {
          $error = true;
          $response['response'] .= "Ello &gt;&gt; Plugin host error - CODE - 03 ";
      }
  
  
      if(!$error) {
          $response['success'] = true;
          $response['response'] .= "Ello &gt;&gt; Auth OK ";
      }
  
      echo json_encode($response);
      die();
  }
  </code></pre>
  
  <p>So the code is here.
  My problem is when I try to load the sender site it is just loading and loading for ever and I doesn't get back the result. Could you tell me what could be the problem with this method? Thanks all of your answers!</p>