Я получаю следующую ошибку при попытке обновить CampaignCriterions
для Campaign
используя PHP SDK для Bing Ads Api.
В поисках решения я наткнулся этот пример кода и попытался закодировать объекты с помощью 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: Biddable Кампания Критерий
BiddableCampaignCriterion добавляется и получает свойства из CampaignCriterion, который теперь является абстрактным базовым классом. Вы должны использовать 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
Других решений пока нет …