· 7 years ago · Nov 05, 2018, 05:46 PM
1$url='https://secure2.tpgrewards.com/tpgapi/job_setup/';
2$data = array(
3 "request" =>"create/update",
4 "edit" => 0,
5 "admin" => 1,
6 "general" => array(
7 "job" => "test",
8 "seller" => "jo",
9 "helper" => "jo",
10 "prgrm_name" => "red",
11 "prgrm_start" => "2018-10-21",
12 "prgrm_end" => "2018-10-22",
13 "notes" => "xzczxcz",
14 "url" => "xzczxcz",
15 "google_analytics" => "1"
16 ),
17 "drvs" => array(
18 "submissions_start_date" => "2018-10-21",
19 "submissions_end_date" => "2018-11-22",
20 "receipt_start_date" => "2018-10-25",
21 "receipt_end_date" => "2018-11-23",
22 "prgrm_email_addrs" => "xzczxcz",
23 "email_domain" => "xzczxcz",
24 "email_subject_drvs" => "sfdsfsfsafs",
25 "reply_email_submission" => "xzczxcz",
26 "client_reply_email_submission" => "xzczxcz",
27 "client_reply_email_domain" => "sfdsfsfsafs",
28
29 "api_partner" => "xzczxcz",
30 "api_reply_email" => "xzczxcz",
31 "drvsIPAddresses" => "sfdsfsfsafs",
32
33 "html_email" => 0,
34 "valid_submisns" => 1,
35
36 "household_limit" => 0,
37 "needs_codes" => 1,
38 "needs_external_codes" => 0,
39 "job_type" => 1,
40
41 "dollar_threshold" => 0,
42 "count_threshold" => 1,
43 "strikes" => 0,
44 "day_play" => 1,
45 ),
46 "redemption" => array(
47 "code_prefix" => "000",
48 "code_start_date" => "2018-10-21",
49 "code_exp_date" => "2018-10-22",
50 "reward_type" => "giftCard",
51 "primary_provider" => "first_view_e_cards",
52 "secondary_provider" => "trnsc_e_cards",
53 "google_analytics" => "1",
54 "cable" => 0,
55 "electric" => 1,
56 "gas" => 0,
57 "phone" => 1,
58 "water" => 1,
59 "reward_exp_date" => "2018-11-22",
60
61 "reward_value" => 0,
62 "number_rewards" => 1,
63 "reward_per_code" => 0,
64 "codes_to_enter" => 1,
65 "number_of_codes" => 1,
66
67 "number_of_rewards_per_limit" => 0,
68 "needs_codes_redemption" => 1,
69 "external_codes_redemption" => 0,
70 "needs_CAPTCHA" => 0,
71
72 "site_key" => "giftCard",
73 "secret_key" => "first_view_e_cards",
74 "email_subject_redemption" => "trnsc_e_cards",
75 "reward_api" => "xcvcxvcxv1",
76
77 ),
78);
79$dataJson = json_encode($data);
80
81try {
82 $ch = curl_init();
83
84 // Check if initialization had gone wrong*
85 if ($ch === false) {
86 throw new Exception('failed to initialize');
87 }
88
89 curl_setopt($ch, CURLOPT_URL, 'https://secure2.tpgrewards.com/tpgapi/job_setup/');
90 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
91 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
92 curl_setopt($ch, CURLOPT_POSTFIELDS, $dataJson);
93 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
94 'Content-Type: application/json',
95 'Content-Length: ' . strlen($dataJson))
96 );
97
98 $content = curl_exec($ch);
99
100 // Check the return value of curl_exec(), too
101 if ($content === false) {
102 throw new Exception(curl_error($ch), curl_errno($ch));
103 }else{
104 //var_dump($content);
105 echo 'Result is '.$content;
106 }
107
108 /* Process $content here */
109
110 // Close curl handle
111 curl_close($ch);
112} catch(Exception $e) {
113
114 trigger_error(sprintf(
115 'Curl failed with error #%d: %s',
116 $e->getCode(), $e->getMessage()),
117 E_USER_ERROR);
118
119}