有些联盟只允许填入一个tracker的post back url,这对于同时使用好几个tracker的话实在是不方便,因此我想使用中转的办法,一个中转服务器收到联盟的postback url,然后再把track.php?subid=XXXX(以imobitrax为例)转发到其它几个tracker上,自己捣鼓了一下没成功,有人帮忙看看问题在哪吗?
) f" E# b, t! I9 |& S3 i- a/ B0 a1 C, `! ]/ f
<?php $subid=$_POST["subid"]; ?>
2 P9 O _- e" L: V- E3 W<?php
' L( b- L) V5 m4 _function send_post($url, $post_data) { * s: [0 C4 x$ I9 _/ W) z5 O8 M: Z. Z& P
# R. p; Q3 i- N5 ` $postdata = http_build_query($post_data); 3 | Y! \2 G2 X( O8 k
$options = array( ! M! S5 t# Q5 v5 e# o, T9 {8 b- }
'http' => array( 9 u/ E8 b7 m) S6 L, q* q
'method' => 'POST',
" u3 _+ V2 |! s/ \6 J 'header' => 'Content-type:application/x-www-form-urlencoded',
+ T# k3 E! g: y 'content' => $postdata, 4 B! H% }5 I, _& D3 ?2 L6 q8 k
'timeout' => 15 * 60 // 超时时间(单位:s)
% P# g$ M* V8 H: C ) 6 {7 A- X5 Y/ h" R/ j, ]; t
); $ C k8 t& `; u1 t( x
$context = stream_context_create($options);
% h- l! E( @4 d3 @8 o( C $result = file_get_contents($url, false, $context);
3 d/ ? m2 u: S. t( t h; a; E! S& x- q/ ]0 W
return $result; 6 M/ R1 C8 N2 L2 H
}
2 u, G+ @9 n B# I7 i
" _( h7 @8 d) f& R# d. y7 v//使用方法 0 r) r( |+ I$ \( Q2 N
$post_data = array(
( g0 B" ^' X w8 t 'subid' => $subid 6 s2 L- r0 _0 Q6 W2 N
);
. N7 i N2 y3 H& y' @5 N( |# e) @send_post('http://1.com/track.php', $post_data); Q' a8 S% `2 G: f1 A
send_post('http://2.com/track.php', $post_data);
1 F" L- }+ d7 V" j) N; Q9 v/ Csend_post('http://3.com/track.php', $post_data); - f$ }* e1 i. [$ C0 L
send_post('http://4.com/track.php', $post_data); # {# T6 Y7 R, g
?>
" Z3 s/ D) l5 K$ G
# N0 P$ F5 _' T3 J% T比如以上这段存为,trackredirect.php ,联盟那里call back url 填入 xxx.com/trackredirect.php?subid={subid},但是我测试了,不工作呢,好头痛,求专业人士帮忙看看哈* A( K1 ~4 D, O# h8 p+ A# C
6 s$ E: _) h. G3 I _
|