1
|
<?php
|
2
|
/**
|
3
|
* i-generation成果通知(セッション方式)サンプルソース
|
4
|
* [必須項目]
|
5
|
* a : アフィリエイトID
|
6
|
* u : 注文番号(会員ID、メールアドレスなど)
|
7
|
* [オプション]
|
8
|
* p : コースID(成果地点が複数ある場合に1〜5の数値を設定)
|
9
|
* am: 売上合計金額(定率報酬の場合必須)
|
10
|
* i : 商品情報(商品単価.注文個数.商品コード)
|
11
|
*/
|
12
|
function conversion_request($a, $u, $p="", $am="", $i=""){
|
13
|
|
14
|
//広告ID(弊社指定の値を入れてください)
|
15
|
$c = "1";
|
16
|
|
17
|
//以下変更不要
|
18
|
$server = "i-generation.jp";
|
19
|
$server_port = "80";
|
20
|
$path = "/action/conversion.php?c=$c&a=$a&u=$u&p=$p&am=$am&i=$i";
|
21
|
$timeout = 10;
|
22
|
$fp = fsockopen($server,$server_port,$err,$timeout);
|
23
|
if($fp){
|
24
|
fputs($fp, "GET $path HTTP/1.1\r\n");
|
25
|
fputs($fp, "Host: $server\r\n");
|
26
|
fputs($fp, "\r\n");
|
27
|
stream_set_timeout($fp, 5);
|
28
|
$header = "";
|
29
|
$body = "";
|
30
|
$header_flg = 0;
|
31
|
while(!feof($fp)){
|
32
|
$line = fgets($fp, 1028);
|
33
|
$socket_data_arr = stream_get_meta_data($fp);
|
34
|
if($socket_data_arr['timed_out']) break;
|
35
|
if(!$header_flg){
|
36
|
$header .= $line;
|
37
|
}
|
38
|
else{
|
39
|
$body .= htmlspecialchars(trim($line));
|
40
|
break;
|
41
|
}
|
42
|
if($line == "\r\n" && !$header_flg) $header_flg = 1;
|
43
|
}
|
44
|
fclose($fp);
|
45
|
if($socket_data_arr['timed_out']){
|
46
|
$result = "TIMEOUT";
|
47
|
}else if($body == "conversion received"){
|
48
|
$result = "OK";
|
49
|
}else{
|
50
|
$result = "NG";
|
51
|
}
|
52
|
}else{
|
53
|
$result = "CONNECT ERROR";
|
54
|
}
|
55
|
return $result;
|
56
|
}
|
57
|
|
58
|
/**
|
59
|
* i-generation退会通知(セッション方式)サンプルソース
|
60
|
* [必須項目]
|
61
|
* a : アフィリエイトID
|
62
|
* u : 注文番号(会員ID、メールアドレスなど)
|
63
|
*/
|
64
|
function resign_request($a, $u){
|
65
|
|
66
|
//広告ID(弊社指定の値を入れてください)
|
67
|
$c = "1";
|
68
|
|
69
|
//以下変更不要
|
70
|
$server = "i-generation.jp";
|
71
|
$server_port = "80";
|
72
|
$path = "/action/resign.php?c=$c&a=$a&u=$u";
|
73
|
$timeout = 10;
|
74
|
$fp = fsockopen($server,$server_port,$err,$timeout);
|
75
|
if($fp){
|
76
|
fputs($fp, "GET $path HTTP/1.1\r\n");
|
77
|
fputs($fp, "Host: $server\r\n");
|
78
|
fputs($fp, "\r\n");
|
79
|
stream_set_timeout($fp, 5);
|
80
|
$header = "";
|
81
|
$body = "";
|
82
|
$header_flg = 0;
|
83
|
while(!feof($fp)){
|
84
|
$line = fgets($fp, 1028);
|
85
|
$socket_data_arr = stream_get_meta_data($fp);
|
86
|
if($socket_data_arr['timed_out']) break;
|
87
|
if(!$header_flg){
|
88
|
$header .= $line;
|
89
|
}
|
90
|
else{
|
91
|
$body .= htmlspecialchars(trim($line));
|
92
|
break;
|
93
|
}
|
94
|
if($line == "\r\n" && !$header_flg) $header_flg = 1;
|
95
|
}
|
96
|
fclose($fp);
|
97
|
if($socket_data_arr['timed_out']){
|
98
|
$result = "TIMEOUT";
|
99
|
}else if($body == "OK"){
|
100
|
$result = "OK";
|
101
|
}else{
|
102
|
$result = "NG";
|
103
|
}
|
104
|
}else{
|
105
|
$result = "CONNECT ERROR";
|
106
|
}
|
107
|
return $result;
|
108
|
}
|
109
|
?>
|