php - :"Missing Image","error_user_msg":"请指定要与此广告一起投放的图片
问题描述
我有这个错误和“缺少图像”,“error_user_msg”:“请指定一个图像与这个广告一起运行。奇怪的是,fcebook 向我返回了我图像的哈希值
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;
错误:
:"Missing Image","error_user_msg":"请指定要与此广告一起运行的图像。图像哈希:7eca2xxxxxxxxxxxxxxxxxxxxxxxxxxxxx 版本:1 GenelralExxception:无效参数GeneralExceptiontype: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) {
解决方案
您好,经过一些测试,我找到了答案:
$object_story_spec->setData(array(
AdCreativeObjectStorySpecFields::PAGE_ID =>
"700584106652751",
AdCreativeObjectStorySpecFields::PHOTO_DATA =>
array ("image_hash" =>$image_hash,),
));
但现在我有另一个问题:
100,"error_subcode":1815520,"is_transient":false,"error_user_title":"广告创意在此处输入代码不使用有效链接","error_user_msg":"此广告中的链接丢失或无效链接点击广告优化。这可能是因为此广告需要链接外部内容(例如,广告客户的网站),但此广告不需要(例如,它链接到 Facebook 页面)。通过使链接有效来修复此错误。
有人可以帮忙吗?
推荐阅读
- r - 如何通过以下错误“readLines(filestocopy)中的错误:'con'不是连接”?
- javascript - 使用汇总捆绑为 esm 时,React 未定义
- git - BUG:unpack-trees.c:699:pos 必须指向此目录中的第一个条目
- c# - 启用 WCF AJAX 的服务创建正常,但方法返回 404
- sql-server - 使用游标时从游标中删除一行
- python - 检查数字是否不是无并做某事的Pythonic方法
- java - RestTemplate.exchange 是否尊重 resonseType 类的验证注释?
- python - How to only do add_widget once in Kivy
- python - 如何更改 Django 身份验证视图“PasswordResetView”以将重新发送的链接发送到手机号码和电子邮件?
- javafx - Java 运行时错误以及加载异常错误