[英]sending clicked information stored in variable from one php site to another
[英]How to incorporate information from one site to another?
可以说我有两个网站www.a.com和www.b.com。 网站www.a.com上有一份通讯订阅表格,我需要将提交的信息合并到网站www.b.com,信息将为订户的姓名,地址,通讯格式和电子邮件ID。 有没有办法做到这一点。 我正在使用PHP。
提前致谢
您可以使用SOAP,AJAX,XMLRPC和其他协议在两个站点之间传递数据。
在www.a.com上处理帖子数据的页面上,您可以执行以下操作:
$url = 'www.b.com/sub.php';
$fields = array(
'name' => urlencode( $_POST['name'] ),
'address' => urlencode( $_POST['address'] ),
'format' => urlencode( $_POST['format'] ),
'emailid' => urlencode( $_POST['emailid'] )
);
foreach($fields as $key=>$value) { $query .= $key.'='.$value.'&'; }
rtrim($query,'&');
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, count( $fields ) );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $query );
curl_exec( $ch );
curl_close( $ch );
然后在www.b.com上像处理常规POST请求一样处理它。
如果只希望两个网站共享信息,则有两种可能性:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.