Reputation: 29
i am having this error and "Missing Image","error_user_msg":"Please specify an image to run with this ad. something weird is tha fcebook return to me a hash for my image
Api::init($APP_ID,$APP_SECRET,$ACCESS_TOKEN);
$user = new AdAccount($account_id);
use FacebookAds\Object\Fields\AdImageFields;
define('SDK_DIR',__DIR__.'\\');
echo "The image is: ".SDK_DIR.$ImagePath. "<br>";
try {
$image = new AdImage(null, $account_id);
$image->{AdImageFields::FILENAME} = SDK_DIR.$ImagePath;
$image->save();
$imageHash = $image->{AdImageFields::HASH}.PHP_EOL;
echo 'Image Hash: '.$imageHash . "<br>";
echo 'version:1'."<br>";
$creative = $user->createAdCreative(
array(), //create an ad creative for general use to our ads
array(
AdCreativeFields::NAME => $AdNameCreative,
AdCreativeFields::TITLE => $AdTitleCreative,
AdCreativeFields::BODY => $BodyAdCreative,
AdCreativeFields::IMAGE_HASH => $imageHash,
AdCreativeFields::OBJECT_URL => $UrlCreative,
)
);
} catch (FacebookAds\Exception\Exception $e) {
echo 'GenelralExxception: ' . $e->getMessage();
echo 'GeneralExceptiontype:'. $e->getCode();
echo 'typeException:' . var_dump($e);
// echo 'the sub code is: ' . $e->getSubErrorCode();
//$previousException = $e->getPrevious();
// Do some further processing on $previousException
exit;
}catch (FacebookAds\Http\Exception\EmptyResponseException $e) {
echo 'Message: ' . $e->getMessage();
echo 'Type:'. var_dump($e);
//$previousException = $e->getPrevious();
// Do some further processing on $previousException
exit;
}catch (FacebookAds\Http\Exception\AuthorizationException $e) {
echo 'AuthorizationException: ' . $e->getMessage()."<br>";
echo 'AuthorizationExceptiontype:'. $e->getCode()."<br>";
echo 'typeAuthorization:' . var_dump($e);
//$previousException = $e->getPrevious();
// Do some further processing on $previousException
print_r($e);
exit;
}
$creativeId = $creative->id;
Error :
:"Missing Image","error_user_msg":"Please specify an image to run with this ad.Image Hash: 7eca2xxxxxxxxxxxxxxxxxxxxxxxxxx version:1 GenelralExxception: Invalid parameterGeneralExceptiontype:100object(FacebookAds\Http\Exception\AuthorizationException)#43 (16) { ["response":protected]=> object(FacebookAds\Http\Response)#41 (5) { ["request":protected]=> object(FacebookAds\Http\Request)#39 (10) { ["client":protected]=> object(FacebookAds\Http\Client)#4 (6) { ["requestPrototype":protected]=> object(FacebookAds\Http\Request)#18 (10) {
Upvotes: 2
Views: 1322
Reputation: 29
Hello after some tests i found the answer:
$object_story_spec->setData(array(
AdCreativeObjectStorySpecFields::PAGE_ID =>
"700584106652751",
AdCreativeObjectStorySpecFields::PHOTO_DATA =>
array ("image_hash" =>$image_hash,),
));
but now i have an other problem:
100,"error_subcode":1815520,"is_transient":false,"error_user_title":"Ad Creative enter code hereDoes Not Use Valid Link","error_user_msg":"The link in this ad is either missing or invalid for Link Click Ads optimization. This could be because this ad needs to link external content (e.g., an advertiser's website), but this ad does not (e.g., it links to a Facebook page). Fix this error by making the link valid.
Could anyone help?
Upvotes: 1