PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, December 28, 2021

[FIXED] Facebook Error #100 when uploading Offline Conversions using Marketing API

 December 28, 2021     facebook, facebook-graph-api, facebook-javascript-sdk, facebook-php-sdk     No comments   

Issue

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


Solution

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.



Answered By - Anthony B
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing