|
 |
|
สอบถามในการใช้ PHP CURL Post ค่าไป server1 และรับค่ากลับจาก Server2 รบกวนด้วยครับทุกท่านครับ |
|
 |
|
|
 |
 |
|
สอบถามในการใช้ PHP CURL Post ค่าไป server1 และรับค่ากลับจาก Server2
Server1 เป็นคนส่งค่าไป Server2
ผมส่งค่าไป มี mobileและname
Code (PHP)
$ret = "mobile_cn=".$mobile_no."&name_cn=".$name;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.Server2.com/curl.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $ret);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
Server2
ผมก็รับค่า
Code (PHP)
$mobile_cn = @$_REQUEST['mobile_cn'];
$name_cn = @$_REQUEST['name_cn'];
$reply="ได้รับแล้วนะ";
//$reply="ค่านี้เปลี่ยนได้";
ผมจะทำยังไงให้ได้รับค่า $reply กลับไปยัง Server1 ได้ ขอบคุณทุกท่านล่วงหน้าครับ
Tag : PHP, Linux, Web Service

|
|
 |
 |
 |
 |
Date :
2014-09-10 18:55:57 |
By :
itpanya |
View :
2034 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
echo $reply;
น่าจะแบบนี้ครับ จากนั้นฝั่ง Request ก็อ่านค่า Result ที่ได้
|
 |
 |
 |
 |
Date :
2014-09-11 10:09:42 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|