skip to Main Content

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);

2

Answers


  1. Same thing just started happening here. Exact same problem. I had to play around for hours… But to get it working, I commented out

    //"content-type: multipart/form-data", 
    

    and it started to work for me. Please let know if that also solves your problem.

    Login or Signup to reply.
  2. It simply means that data is not sent as per documentation. I was facing this issue as in my case "contents" parameter was passing empty string, instead of documentation says that "contents" parameter should contain atleast 2 parameters, that is, quantity and id.

    Go through documentation and you can compare your value format with documentation.

    Here is link for documentation :- https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/custom-data#content-ids

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search