· 9 years ago · Sep 28, 2016, 04:26 AM
1 $ajax_url = admin_url('admin-ajax.php?action=affwp_track_conversion');
2 $aff_id = $this->getAffiliateId();
3 $visit_id = $this->getVisitId();
4 $secretKey = md5((string)$amount . $description . $reference . $context . $status);
5
6 $data = http_build_query(array(
7 'action' => 'affwp_track_conversion',
8 'affiliate' => $aff_id,
9 'amount' => $amount,
10 'status' => $status,
11 'description' => $description,
12 'context' => $context,
13 'reference' => $reference,
14 'campaign' => '',
15 'md5' => $secretKey
16 ));
17
18 $curl = curl_init();
19
20 curl_setopt_array($curl, array(
21 CURLOPT_URL => $ajax_url,
22 CURLOPT_RETURNTRANSFER => true,
23 CURLOPT_ENCODING => "",
24 CURLOPT_MAXREDIRS => 10,
25 CURLOPT_TIMEOUT => 30,
26 CURLOPT_SSL_VERIFYPEER => false,
27 CURLOPT_SSL_VERIFYHOST => false,
28 //CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
29 CURLOPT_CUSTOMREQUEST => "POST",
30 CURLOPT_POSTFIELDS => $data,
31 CURLOPT_HTTPHEADER => array(
32 "Content-Type: application/x-www-form-urlencoded; charset=UTF-8",
33 "Content-Length: " . strlen($data)
34 ),
35 CURLOPT_COOKIE => "affwp_ref=$aff_id; affwp_ref_visit_id=$visit_id",
36 ));
37
38 $response = curl_exec($curl);
39 $err = curl_error($curl);
40
41 curl_close($curl);