I must be missing something because I can't upload a picture along with the database record.
This code works as expected, but fails to add the picture to the featured image field.
Any ideas what I am doing wrong? Thank you.
$zimg="https://content.invisioncic.com/e322713/pages_media/3_1.jpg";
$image = array();
$image['article']=file_get_contents($zimg);
$fields = array();
$fields['18']="title test";
$fields['19']="desc test";
$fields['image']=$image;
$data = array(
"title" => "title test1",
"content" => "content test1",
"status" => "published", // Or "draft"
"category" => 19,
"author" => 191972,
"fields" => $fields,
);
$communityUrl = 'https://www.communityUrl.com/';
$apiKey = 'apiKey';
$curl = curl_init( $communityUrl . 'api/cms/records/7' );
curl_setopt_array( $curl, array(
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => "{$apiKey}:",
CURLOPT_USERAGENT => "MyUserAgent/1.0",
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => http_build_query($data),
) );
$response = curl_exec( $curl );