[PHP-users 35473] Re: HTTP_ClientでxmlデータをPOSTする方法

Akira Saito akrst @ mtb.biglobe.ne.jp
2011年 1月 29日 (土) 14:20:08 JST


こんにちわ。

こことか。。

>           'user' => '$id',
>           'pass' => '$pass',

           'user' => "$id",
           'pass' => "$pass",


----- Original Message ----- 
From: "岩堀嘉郎" <uro @ iwahori.jp>
To: <php-users @ php.gr.jp>
Sent: Thursday, January 27, 2011 9:36 AM
Subject: [PHP-users 35472]HTTP_ClientでxmlデータをPOSTする方法


> rubyで書かれた
> #!/usr/bin/ruby
>
> require 'uri'
> require 'net/http'
>
> Net::HTTP.version_1_1
>
> HOST = "192.168.1.6"
> #!/usr/bin/ruby
>
> require 'uri'
> require 'net/http'
>
> Net::HTTP.version_1_1
>
> HOST = "***.***.*.*"
> PORT = "8000"
> USER = "****"
> PASSWD = "****"
> CONTENT_TYPE = "application/xml"
>
> req = Net::HTTP::Post.new("/orca14/appointmod?class=01")
>
> record_in = <<EOF
> <record>
>   <record name="appointreq">
>     <string name="Patient_ID">415006550</string>
>     <string name="Appointment_Date">2011-01-25</string>
>     <string name="Appointment_Time">15:00:00</string>
>     <string name="Appointment_Id">00001</string>
>     <string name="Department_Code">01</string>
>     <string name="Physician_Code">10002</string>
>     <string name="Appointment_Information">01</string>
>   </record>
> </record>
> EOF
>
> record = ""
> 1.times {|i|
> record += record_in.gsub("__X__", i.to_s)
> }
> BODY = "<data>#{record}</data>"
>
> req.content_length = BODY.size
> req.content_type = CONTENT_TYPE
> req.body = BODY
> req.basic_auth(USER, PASSWD)
> puts req.body
>
> Net::HTTP.start(HOST, PORT) {|http|
> res = http.request(req)
> puts res.body.size
> puts res.body
>
> }
> というプログラムをphpで書き直したいのですが、
>       <?php
>       require_once 'HTTP/Client.php';
>       $url ="http://***.***.*.*:8000/orca14/appointmod?class=01";
>       $id ="****";
>       $pass="****";
>       $loginpara=array(
>           'user' => '$id',
>           'pass' => '$pass',
>           );
>       $data = "<data>
>               <record>
>               <record name=\"appointreq\">
>               <string name=\"Patient_ID\">415000025</string>
>               <string name=\"Appointment_Date\">2011-01-25</string>
>               <string name=\"Appointment_Time\">14:53:00</string>
>               <string name=\"Department_Code\">01</string>
>               <string name=\"Physician_Code\">10001</string>
>               <string name=\"Appointment_Information\">01</string>
>               <string name=\"Appointment_Note\">テストコメント</string>
>               </record>
>               </record>
>               </data>";
>       $client=& new HTTP_Client($logoinpara);
>       $client -> setDefaultHeader('Content-Type', 'application/xml');
>       $client ->post($url, $data);
>       $response = $client->currentResponse();
>       print_r($response);
>       ?>
> としてもなにもデータが送られていない様なレスポンスしか返ってきません。どこが悪いのでしょうか?
> _______________________________________________
> PHP-users mailing list  PHP-users @ php.gr.jp
> http://ml.php.gr.jp/mailman/listinfo/php-users
> PHP初心者のためのページ - 質問する前にはこちらをお読みください
> http://oldwww.php.gr.jp/php/novice.php3
> 



PHP-users メーリングリストの案内