尝试使用 PHP SDK 更新 Bing 广告活动的 CampaignCriterions 时无法创建摘要 class 错误
Cannot create an abstract class error while trying to update CampaignCriterions for a Bing Ads Campaign using PHP SDK
我尝试使用 PHP SDK Bing 广告 Api.[=19= 为 Campaign
更新 CampaignCriterions
时出现以下错误]
在寻找解决方案时,我遇到了 this code example 并尝试使用 SoapVar
对对象进行编码。我仍然遇到同样的错误。也许,我在这里遗漏了一些东西。对此的任何帮助都会很棒。
代码
$criterion = new CampaignCriterion();
$criterion->CampaignId = $campaignCriterion->CampaignId;
$criterion->Criterion = $radiusCriterion;
$criterion->Id = $campaignCriterion->Id;
$criterion->Type = CampaignCriterionType::Radius;
$request = new UpdateCampaignCriterionsRequest();
$request->CampaignCriterions = [$criterion];
try {
return $campaignManagementServiceProxy->GetService()->UpdateCampaignCriterions($request);
} catch (SoapFault $se) {
print_r($se);
}
异常
[ExceptionDetail] => stdClass Object
(
[HelpLink] =>
[InnerException] =>
[Message] => Cannot create an abstract class.
[StackTrace] =>
at System.Runtime.Serialization.FormatterServices.nativeGetUninitializedObject(RuntimeType type)
at ReadCampaignCriterionFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 id, RuntimeTypeHandle declaredTypeHandle, String name, String ns)
at ReadArrayOfCampaignCriterionFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString , XmlDictionaryString , CollectionDataContract )
at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.PartInfo.ReadObject(XmlDictionaryReader reader, XmlObjectSerializer serializer)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
[Type] => System.MemberAccessException
)
更新 09/26: 可出价广告系列标准
添加了 BiddableCampaignCriterion,并从 CampaignCriterion 派生属性,它现在是一个抽象基础 class。在添加、获取和更新活动标准操作中,您必须使用 BiddableCampaignCriterion 而不是 CampaignCriterion。
- 只要
Criterion
、CriterionBid
未使用 SoapVar
加密,就会发生这种情况。
- 最终
CampaignCriterion
应加密为 BiddableCampaignCriterion
您的最终代码应如下所示(注释掉旧代码):
$criterion = new CampaignCriterion();
// $criterion->CampaignId = $campaignCriterion->CampaignId;
$criterion = $campaignCriterion;
// $criterion->Criterion = $radiusCriterion;
$criterion->Criterion = new SoapVar($radiusCriterion, SOAP_ENC_OBJECT, 'RadiusCriterion', $campaignManagementServiceProxy->GetNamespace());
$criterion->Id = $campaignCriterion->Id;
// $criterion->Type = CampaignCriterionType::Radius;
$criterion->CriterionBid = new SoapVar($campaignCriterion->CriterionBid, SOAP_ENC_OBJECT, 'BidMultiplier', $campaignManagementServiceProxy->GetNamespace());
$request = new UpdateCampaignCriterionsRequest();
// $request->CampaignCriterions = [$criterion];
$request->CampaignCriterions = [new SoapVar($criterion, SOAP_ENC_OBJECT, 'BiddableCampaignCriterion', $campaignManagementServiceProxy->GetNamespace());];
try {
return $campaignManagementServiceProxy->GetService()->UpdateCampaignCriterions($request);
} catch (SoapFault $se) {
print_r($se);
}
参考文献:
- https://msdn.microsoft.com/en-us/library/bing-ads-campaign-management-radiuscriterion.aspx
- https://msdn.microsoft.com/en-us/library/mt807658%28v=msads.110%29.aspx?f=255&MSPPError=-2147217396
我尝试使用 PHP SDK Bing 广告 Api.[=19= 为 Campaign
更新 CampaignCriterions
时出现以下错误]
在寻找解决方案时,我遇到了 this code example 并尝试使用 SoapVar
对对象进行编码。我仍然遇到同样的错误。也许,我在这里遗漏了一些东西。对此的任何帮助都会很棒。
代码
$criterion = new CampaignCriterion();
$criterion->CampaignId = $campaignCriterion->CampaignId;
$criterion->Criterion = $radiusCriterion;
$criterion->Id = $campaignCriterion->Id;
$criterion->Type = CampaignCriterionType::Radius;
$request = new UpdateCampaignCriterionsRequest();
$request->CampaignCriterions = [$criterion];
try {
return $campaignManagementServiceProxy->GetService()->UpdateCampaignCriterions($request);
} catch (SoapFault $se) {
print_r($se);
}
异常
[ExceptionDetail] => stdClass Object
(
[HelpLink] =>
[InnerException] =>
[Message] => Cannot create an abstract class.
[StackTrace] =>
at System.Runtime.Serialization.FormatterServices.nativeGetUninitializedObject(RuntimeType type)
at ReadCampaignCriterionFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 id, RuntimeTypeHandle declaredTypeHandle, String name, String ns)
at ReadArrayOfCampaignCriterionFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString , XmlDictionaryString , CollectionDataContract )
at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.PartInfo.ReadObject(XmlDictionaryReader reader, XmlObjectSerializer serializer)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
[Type] => System.MemberAccessException
)
更新 09/26: 可出价广告系列标准 添加了 BiddableCampaignCriterion,并从 CampaignCriterion 派生属性,它现在是一个抽象基础 class。在添加、获取和更新活动标准操作中,您必须使用 BiddableCampaignCriterion 而不是 CampaignCriterion。
- 只要
Criterion
、CriterionBid
未使用SoapVar
加密,就会发生这种情况。 - 最终
CampaignCriterion
应加密为BiddableCampaignCriterion
您的最终代码应如下所示(注释掉旧代码):
$criterion = new CampaignCriterion();
// $criterion->CampaignId = $campaignCriterion->CampaignId;
$criterion = $campaignCriterion;
// $criterion->Criterion = $radiusCriterion;
$criterion->Criterion = new SoapVar($radiusCriterion, SOAP_ENC_OBJECT, 'RadiusCriterion', $campaignManagementServiceProxy->GetNamespace());
$criterion->Id = $campaignCriterion->Id;
// $criterion->Type = CampaignCriterionType::Radius;
$criterion->CriterionBid = new SoapVar($campaignCriterion->CriterionBid, SOAP_ENC_OBJECT, 'BidMultiplier', $campaignManagementServiceProxy->GetNamespace());
$request = new UpdateCampaignCriterionsRequest();
// $request->CampaignCriterions = [$criterion];
$request->CampaignCriterions = [new SoapVar($criterion, SOAP_ENC_OBJECT, 'BiddableCampaignCriterion', $campaignManagementServiceProxy->GetNamespace());];
try {
return $campaignManagementServiceProxy->GetService()->UpdateCampaignCriterions($request);
} catch (SoapFault $se) {
print_r($se);
}
参考文献: - https://msdn.microsoft.com/en-us/library/bing-ads-campaign-management-radiuscriterion.aspx - https://msdn.microsoft.com/en-us/library/mt807658%28v=msads.110%29.aspx?f=255&MSPPError=-2147217396