数据不会使用curl暂停到API

时间:2013-09-03 02:45:24

标签: php api curl

电子邮件不会暂停到API

 <?php 
   function post_to_url($url, $data) {
       $ch = curl_init();
       curl_setopt($ch, CURLOPT_URL, $url);
       curl_setopt($ch, CURLOPT_POST, 1);
       curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
       $result = curl_exec ($ch);
       echo $result;
       curl_close ($ch);
   }
   $data = array( "email1" => "myemail@yahoo.com" );

   post_to_url("http://api.payquicker.com/api/IsActiveAccount?email=", $data);

 ?>

echo $result;应该是----&gt; http://api.payquicker.com/api/IsActiveAccount?email=myemail@yahoo.com

但我只获得http://api.payquicker.com/api/IsActiveAccount?email=

1 个答案:

答案 0 :(得分:0)

 echo "<p><strong>SEND INVITATION</strong></p></BR>";
 $dataw = array(
            "authorizedKey" => "xxx-xxxx-xxx",
            "senderEmail" => "senderemail@yahoo.com",
            "recipientEmail" => "myemail@yahoo.com"
          );
$url_send ="https://api.payquicker.com/api/SendInvitation?authorizedKey=xxx-xxxx-xxx";
$str_data = json_encode($dataw);
function send_invitation($url, $post_data){
  $url_send =$url;
  $ch = curl_init($url_send);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,  false);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST,   "POST");
  curl_setopt($ch, CURLOPT_POSTFIELDS,      $post_data);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,  true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',     
 'Content-Length: ' . strlen($post_data))
 );
   $result = curl_exec($ch);
  //$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);
  return $result; 
  }
 echo "RESULT :" . send_invitation($url_send, $str_data);