有些联盟只允许填入一个tracker的post back url,这对于同时使用好几个tracker的话实在是不方便,因此我想使用中转的办法,一个中转服务器收到联盟的postback url,然后再把track.php?subid=XXXX(以imobitrax为例)转发到其它几个tracker上,自己捣鼓了一下没成功,有人帮忙看看问题在哪吗?
: g5 v) D, n' ?
& [ T- Q/ q/ Z<?php $subid=$_POST["subid"]; ?>
7 z' @' p' A( H' _0 L<?php
! U' _ n5 C) T b# @function send_post($url, $post_data) {
' t, g& \2 E1 f- \8 K% T& q4 w* N" J: O7 @$ ~4 n4 C5 S
$postdata = http_build_query($post_data); [& Y1 ?3 R1 {. b& \; J
$options = array( 0 P% X) Y, Z/ D- c
'http' => array(
& E1 T6 F( r/ I3 H1 j 'method' => 'POST',
( @# r* K. B/ S3 x. s2 q# ?0 p/ s6 G 'header' => 'Content-type:application/x-www-form-urlencoded', 4 y. ^7 w# r* d8 E( C
'content' => $postdata, . Z7 C% @% \ S) r, Q# J9 V+ E+ X; b
'timeout' => 15 * 60 // 超时时间(单位:s)
' {2 |+ r' {3 U ) 5 r$ q( }# f# j! b! c
);
. Q D' f9 j3 Q' c2 \ $context = stream_context_create($options);
}) A7 Q3 _+ K% u) C! B $result = file_get_contents($url, false, $context); 5 d& D8 `& v7 x5 B. @. d
6 k j- `" {( G7 `: c8 J. V% I; G0 w' _
return $result;
; |1 a8 W8 c7 t. }- Z}
8 N. W7 ^* `4 q; M( O; E* ^' ~3 w8 U0 c* h
//使用方法
- z! ?! I8 ?$ y" m2 z) U8 N! P$post_data = array( * t$ {: j! }3 P# Q
'subid' => $subid * m0 E- O% j5 R
); ' [* n- D# b$ V5 p6 r+ q' C7 @3 T
send_post('http://1.com/track.php', $post_data); 0 F1 u7 }4 @" ~8 `$ P G
send_post('http://2.com/track.php', $post_data); 2 ^, ^8 `, H1 K9 U' V7 ^2 }8 C: l
send_post('http://3.com/track.php', $post_data); . H4 ?" G3 T t, h3 H
send_post('http://4.com/track.php', $post_data);
' t/ \$ M( {& s9 I?>- [/ Y# Q, O1 q3 t: e
/ x7 z( Q( x0 j+ }5 v
比如以上这段存为,trackredirect.php ,联盟那里call back url 填入 xxx.com/trackredirect.php?subid={subid},但是我测试了,不工作呢,好头痛,求专业人士帮忙看看哈
@5 L6 u3 O# [# Q7 I' b1 e }/ w8 R& I: H- L7 c! A0 G
|