I am using the the Facebook Marketing API to upload offline conversions.
The attached code was working until about 2 weeks ago and now reports the following error.
{"error":{"message":"(#100) The parameter data is required","type":"OAuthException","code":100,"fbtrace_id":"HkpzkWB1I5g"}}
I don't understand why it should simply stop working after working as expected for so long. I don't know how to fix it. Any ideas?
$data=array(); $data["match_keys"]["email"]=$emails; $data["match_keys"]["phone"]=$mobiles; $data["match_keys"]["fn"]=hash("sha256",$first_name); $data["match_keys"]["ln"]=hash("sha256",$last_name); $data["match_keys"]["ln"]=hash("sha256",$last_name); $data["match_keys"]["ct"]=hash("sha256",$suburb); $data["match_keys"]["zip"]=hash("sha256",$postcode); $data["match_keys"]["country"]=hash("sha256","Australia"); $data["event_time"] = strtotime($order_date); $data["event_name"] = "Purchase"; $data["currency"] = "AUD"; $data["value"] = $order_total; $data['order_id']=$order_id; $access_token = '<access_token_0>'; // PURCHASE DATA $data_json = json_encode(array($data)); $fields = array(); $fields['access_token'] = $access_token; $fields['upload_tag'] = uniqid() // You should set a tag here (feel free to adjust) $fields['data'] = $data_json; $ch = curl_init(); curl_setopt_array($ch, array( // Replace with your offline_event_set_id CURLOPT_URL => "https://graph.facebook.com/v2.12/1696501357346693/events", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => http_build_query($fields), CURLOPT_HTTPHEADER => array( "cache-control: no-cache", "content-type: multipart/form-data", "Accept: application/json" ), )); $result = curl_exec($ch); echo "\nResult encode"; echo ($result); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } curl_close ($ch);