有些联盟只允许填入一个tracker的post back url,这对于同时使用好几个tracker的话实在是不方便,因此我想使用中转的办法,一个中转服务器收到联盟的postback url,然后再把track.php?subid=XXXX(以imobitrax为例)转发到其它几个tracker上,自己捣鼓了一下没成功,有人帮忙看看问题在哪吗?
! o8 p8 ^0 X4 F4 f3 S# M6 |) ~& A) ~8 v, O9 j) w! e* q
<?php $subid=$_POST["subid"]; ?>9 V, e" u- K5 Q8 K6 r* J
<?php6 v0 F' v1 x% E: V8 |
function send_post($url, $post_data) { 6 T1 w; t# f7 e8 I% K
1 X/ ?/ K e l+ n# } $postdata = http_build_query($post_data); 0 t: p( U8 e7 X0 g# F( p9 s
$options = array( 7 \4 V5 }) f5 w! ?. N
'http' => array(
5 \- k+ `6 l0 ~# K 'method' => 'POST',
9 T1 R" L1 K; ]1 l; z# `' K 'header' => 'Content-type:application/x-www-form-urlencoded', 8 ^5 @; \, |- C K: [2 u" g
'content' => $postdata,
) N: v8 `$ s) r 'timeout' => 15 * 60 // 超时时间(单位:s) * B6 J$ [+ ~; N, Z5 W, M! U
)
: t7 r- g' f: c% d! Y ); * L3 D I$ i) j# J2 L
$context = stream_context_create($options); ' E8 d! I6 R4 M, ~% ^ k( z8 M6 z
$result = file_get_contents($url, false, $context); 3 | I! s0 l1 h- L" `% _! B7 a
/ D8 N9 T( m, S V% Q
return $result;
& L' U2 n j7 c/ b) A# W' C& B}
7 f' q' {4 N) _5 [0 O
7 u9 F" B) f* ^//使用方法
& x- \ |& t8 ]$post_data = array( ) z- C5 k" d$ ]2 y2 ~# E
'subid' => $subid
% c+ ]6 O' a9 |+ s0 W);
8 T* H; C/ `4 Q9 e# W* |$ Psend_post('http://1.com/track.php', $post_data); ; u7 O; }* L" Y5 o
send_post('http://2.com/track.php', $post_data);
- K6 H- P$ \; }, D. s9 j% R9 Csend_post('http://3.com/track.php', $post_data); ; z% h. g: a4 D7 Q9 g
send_post('http://4.com/track.php', $post_data); 4 f5 a. {5 i. L0 |+ q2 R- i
?>
& v+ c5 ?6 Y- K# b
+ m/ w- C% ?4 k- S: Q, f3 ~比如以上这段存为,trackredirect.php ,联盟那里call back url 填入 xxx.com/trackredirect.php?subid={subid},但是我测试了,不工作呢,好头痛,求专业人士帮忙看看哈
) |# n- x0 r/ R8 h) P5 s7 d( y
|