PHP SOAP Request to Bing Ads API - php

I'm having a tough time figuring out how to properly code sequenced SOAP requests to the Bing Ads API. Prefer not to use their SDK, which I have used in the past.
The parameters 'Scope', 'Time', 'Filter', and 'Sort' do not affect the result. The entire account keywords are returned instead. For 'Scope', I am using the Adgroups param to select keywords in that Adgroup. Any help is greatly appreciated.
Reference: https://learn.microsoft.com/en-us/advertising/reporting-service/keywordperformancereportrequest?view=bingads-13
WSDL: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V13/ReportingService.svc?singleWsdl
$request = [
'ReportRequest' => new SoapVar(
[
'Format' => 'Csv',
'ReportName' => 'Bing Keyword Performance Report',
'ReturnOnlyCompleteData' => false,
'Aggregation' => 'Daily',
'Sort' => array('SortColumn' => 'Clicks','SortOrder' => 'Ascending'),
'Scope' => ['AdGroups' => array(array('AccountId' => $bClientId,
'AdGroupId' => $apiDBIdGroupBing,
'CampaignId' => $apiDBIdCampaignBing,
))],
'Time' => [
'CustomDateRangeStart' =>
array('Day' => $startDay,'Month' => $startMonth,'Year' => $startYear),
'CustomDateRangeEnd' =>
array('Day' => $endDay,'Month' => $endMonth,'Year' => $endYear)
],
'Filter' => ['Keywords' => array($criteriaValue)],
'Columns' => [
"TimePeriod",
"Spend",
"Clicks",
"CurrentMaxCpc",
"Impressions",
"AdGroupName"
]
],
SOAP_ENC_OBJECT,
'KeywordPerformanceReportRequest',
"https://bingads.microsoft.com/Reporting/v13"
)];

Solved:
$request = [
'ReportRequest' => new SoapVar(
[
'Format' => 'Csv',
'ReportName' => 'Bing Keyword Performance Report',
'ReturnOnlyCompleteData' => false,
'Aggregation' => 'Monthly',
'Sort' => array('SortColumn' => 'Clicks','SortOrder' => 'Ascending'),
'Scope' => ['AccountIds' => [$bClientId]],
'MaxRows' => '9000000',
'Time' => ['PredefinedTime' => $reportTimeFrame],
'Columns' => [
"Keyword",
"Spend",
"CampaignId",
"AdGroupId",
"AveragePosition",
"CurrentMaxCpc",
"KeywordId",
"BidMatchType",
"Impressions",
"Clicks",
"TimePeriod",
"QualityScore",
"ExpectedCtr",
"AdRelevance",
"LandingPageExperience",
"CampaignStatus",
"AdGroupStatus",
"KeywordStatus",
"AccountName",
"CampaignName",
"AdGroupName",
"BidStrategyType",
]
],
SOAP_ENC_OBJECT,
'KeywordPerformanceReportRequest',
"https://bingads.microsoft.com/Reporting/v13"
)];
$response = $SoapClient->SubmitGenerateReport($request);

Related

Implement Logout on Simplesamlphp

I'm new to this SimpleSamlPhp. I setup the SimpleSamlPhp as requirement from 3rd party for SSO. We've exchanged the metadata. For now, I can successfully login through the SSO, but I can't figure out how to logout. I have tried some suggestions from the internet but still fail. After logout, I'm still able to access the page. The problem is, it seems the cookies not cleared when I run this code:
$as = new SimpleSAML_Auth_Simple('default-sp');
$as = \SimpleSAML\Session::getSessionFromRequest();
$as->logout(array(
'ReturnTo' => '[3rd party home page]',
'ReturnStateParam' => 'LogoutState',
'ReturnStateStage' => 'MyLogoutState',
));
SimpleSAML_Session::getSessionFromRequest()->cleanup();
Here is my setup:
saml20-idp-remote.php
$metadata['https://[mydomain]/simplesaml/saml2/idp/metadata.php'] = [
'metadata-set' => 'saml20-idp-remote',
'entityid' => 'https://[mydomain]/simplesaml/saml2/idp/metadata.php',
'SingleSignOnService' => [
[
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'https://[mydomain]/simplesaml/saml2/idp/SSOService.php',
],
],
'SingleLogoutService' => [
[
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'https://[mydomain]/simplesaml/saml2/idp/SingleLogoutService.php',
],
],
'certData' => '[somerandomkey]',
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
'contacts' => [
[
'emailAddress' => 'myemail#gmail.com',
'contactType' => 'technical',
'givenName' => 'myname',
],
],
];
saml20-sp-remote.php
$metadata['https://[3rdparty domain]/module.php/saml/sp/metadata.php/default-sp'] = [
'entityid' => 'https://[3rdparty domain]/module.php/saml/sp/metadata.php/default-sp',
'contacts' => [
[
'contactType' => 'technical',
'givenName' => 'Administrator',
'emailAddress' => [
'support#3rdpartydomain.com',
],
],
],
'metadata-set' => 'saml20-sp-remote',
'AssertionConsumerService' => [
[
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
'Location' => 'https://[3rdparty domain]/module.php/saml/sp/saml2-acs.php/default-sp',
'index' => 0,
],
[
'Binding' => 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post',
'Location' => 'https://[3rdparty domain]/module.php/saml/sp/saml1-acs.php/default-sp',
'index' => 1,
],
[
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',
'Location' => 'https://[3rdparty domain]/module.php/saml/sp/saml2-acs.php/default-sp',
'index' => 2,
],
[
'Binding' => 'urn:oasis:names:tc:SAML:1.0:profiles:artifact-01',
'Location' => 'https://[3rdparty domain]/module.php/saml/sp/saml1-acs.php/default-sp/artifact',
'index' => 3,
],
],
'SingleLogoutService' => [
[
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'https://[3rdparty domain]/module.php/saml/sp/saml2-logout.php/default-sp',
],
[
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:SOAP',
'Location' => 'https://[3rdparty domain]/module.php/saml/sp/saml2-logout.php/default-sp',
],
],
];
authsources.php
'default-sp' => [
'saml:SP',
'entityID' => 'https://[3rdparty domain]/module.php/saml/sp/metadata.php/default-sp',
'idp' => 'https://[mydomain]/simplesaml/saml2/idp/',
'discoURL' => null,
],
I'm guessing, I make some wrong setup in this authsources.php, but I don't know which one, cause I'm still very very new to this saml. I need your help guys, please bear with me.
Thanks.

Writing record with MeasureValues error: Please use measureValue to send the data

I am writing to Timestream a list of dimensions and a list of measureValues but I keep getting this error:
"Message":"measureValues (list) not supported for BOOL, DOUBLE, VARCHAR and BIGINT data types. Please use measureValue to send the data."
Here is my code:
$dimensions= [];
$dimensions[] = [
'Dimensions' => [
[
'DimensionValueType' => 'VARCHAR',
'Name' => 'id',
'Value' => '123456',
],
],
'MeasureValues' => [
[
'Name' => 'remark',
'Type' => 'VARCHAR',
'Value' => 'Some test text',
],
]
];
$query = [
'CommonAttributes' => [
'MeasureName' => 'table_cnt',
'MeasureValue' => 'table_cnt',
'MeasureValueType' => 'VARCHAR',
'Time' => '1651501311000',
'TimeUnit' => 'MILLISECONDS',
'Version' => 1,
],
'DatabaseName' => 'mydb',
'Records' => $dimensions,
'TableName' => 'table',
];
$db->WriteRecords($query);
According to AWS documentation here (Parameter Syntax) it clearly shows that the supported data types are "DOUBLE|BIGINT|VARCHAR|BOOLEAN|TIMESTAMP|MULTI". If you check a bit down below under "MeasureValues" bulletpoint, it says the opposite: "This is only allowed for type MULTI." . Eitherway, I did try to change the type to MULTI but it still throws the same error.
As you're expecting to use the format
[
'Name' => 'remark',
'Type' => 'VARCHAR',
'Value' => 'Some test text',
],
as input to measures, you need to declare the MeasureValueType as 'MULTI' and not send a MeasureValue on the body of the request. In your example, the final request would be like this:
$dimensions= [];
$dimensions[] = [
'Dimensions' => [
[
'DimensionValueType' => 'VARCHAR',
'Name' => 'id',
'Value' => '123456',
],
],
'MeasureValues' => [
[
'Name' => 'remark',
'Type' => 'VARCHAR',
'Value' => 'Some test text',
],
]
];
$query = [
'CommonAttributes' => [
'MeasureName' => 'table_cnt',
// Removed MeasureValue from here as it's MULTI
'MeasureValueType' => 'MULTI', // <- changed from 'VARCHAR' to 'MULTI'
'Time' => '1651501311000',
'TimeUnit' => 'MILLISECONDS',
'Version' => 1,
],
'DatabaseName' => 'mydb',
'Records' => $dimensions,
'TableName' => 'table',
];
$db->WriteRecords($query);
As a reference, I would suggest you to try it first without the CommonAttributes, as you're inserting only one record, like I demonstrate on this article: https://du7.medium.com/aws-timestream-multi-measures-71b41c089af4

Docusign not prefilling documents before sending

I am having issues when sending documents for a recipient to sign it. The documents should be prefilled using the data from my database which works fine. I know this because when I var_dump $this->textTabs I can see the data. $global is false.
The issue I am having is that when the recipient receives an email to sign the document, the fields which should be prefilled are blank. The Data Label matches the tabLabel in the code below and image
$this->textTabs = [
[
'tabLabel' => 'RegisteredName',
'value' => $contactData->company->name,
'global' => $global,
],
[
'tabLabel' => 'NumberOfEmployees',
'value' => $contactData->company->employee_size,
'global' => $global,
],
[
'tabLabel' => 'RegisteredNumber',
'value' => $contactData->company->reg_no,
'global' => $global,
],
[
'tabLabel' => 'SupplyAddress',
'value' => $supplyAddress_1 . $supplyAddress_2 . $supplyCity . $supplyTown . $supplyCounty . $supplyPostcode,
'global' => $global,
],
[
'tabLabel' => 'SicCode',
'value' => $contactData->company->gapSite->scat_code,
'global' => $global,
],
[
'tabLabel' => 'Recipient_UserTitle',
'value' => $title,
'global' => $global,
],
[
'tabLabel' => 'Recipient_UserName',
'value' => $title . $firstName . $lastName,
'global' => $global,
],
[
'tabLabel' => 'Recipient_Email',
'value' => $contactData->email,
'global' => $global,
],
[
'tabLabel' => 'ContactTelephone',
'value' => $contactData->telephone,
'global' => $global,
],
];
private function send(string $status): ?array
{
try {
return Docusign::createEnvelope([
'templateId' => $this->templateId,
'emailSubject' => $this->emailSubject,
'status' => $status,
'templateRoles' => [
[
'name' => $this->recipient['name'],
'email' => $this->recipient['email'],
'roleName' => 'Client',
'tabs' => [
'textTabs' => $this->textTabs,
/* 'signHereTabs' => [
[
"xPosition" => 400,
"yPosition" => 263,
"documentId" => 1,
"pageNumber" => 6
]
],
*/
]
]
],
'eventNotification' => [
'url' => 'https://webhook.site/697fabec-145a-491f-87ce-1d62be82b298',
'LoggingEnabled' => true,
'RequireAcknowledgment' => true,
'UseSoapInterface' => false,
'IncludeCertificateWithSoap' => false,
'SignMessageWithX509Cert' => false,
'includeDocuments' => true,
'includeEnvelopeVoidReason' => true,
'includeTimeZone' => true,
'includeSenderAccountAsCustomField' => true,
'includeDocumentFields' => true,
'includeCertificateOfCompletion' => true,
'envelopeEventStatusCode' => $this->getRecipientEvents(),
'recipientEvents' => $this->getEventNotification(),
]
]);
} catch (\Exception $e) {
}
}
The fact That recipient receives the email to sign the document, already eliminate any issue to do with my code but why is it not prefilling with the data?
After a while, I decided to create a new docusign account and this seems to have solved the issue. I believe my account was bugger or maybe some technical issue on docusign,

How do you define a Cassandra CollectionMap nested in a UDT with duoshuo's PHP client library?

I have a CollectionSet<UDT> where UDT contains a CollectionMap<int,boolean>. I have not been able to find any documentation or example of how to define this when creating a new Cassandra\Type\CollectionSet for inserting into the table. There is a great example with a CollectionList (found here) which is like this:
// CollectionSet<UDT>, where UDT contains: Int, Text, Boolean,
// CollectionList<Text>, CollectionList<UDT>
new Cassandra\Type\CollectionSet([
[
'id' => 1,
'name' => 'string',
'active' => true,
'friends' => ['string1', 'string2', 'string3'],
'drinks' => [['qty' => 5, 'brand' => 'Pepsi'], ['qty' => 3, 'brand' => 'Coke']]
],[
'id' => 2,
'name' => 'string',
'active' => false,
'friends' => ['string4', 'string5', 'string6'],
'drinks' => []
]
], [
[
'type' => Cassandra\Type\Base::UDT,
'definition' => [
'id' => Cassandra\Type\Base::INT,
'name' => Cassandra\Type\Base::VARCHAR,
'active' => Cassandra\Type\Base::BOOLEAN,
'friends' => [
'type' => Cassandra\Type\Base::COLLECTION_LIST,
'value' => Cassandra\Type\Base::VARCHAR
],
'drinks' => [
'type' => Cassandra\Type\Base::COLLECTION_LIST,
'value' => [
'type' => Cassandra\Type\Base::UDT,
'typeMap' => [
'qty' => Cassandra\Type\Base::INT,
'brand' => Cassandra\Type\Base::VARCHAR
]
]
]
]
]
]);
I've tried using the above example with several variations to accommodate the CollectionMap but nothing is working. My last attempt was this
new Cassandra\Type\CollectionSet($udt_array, [[
'type'=>Cassandra\Type\Base::UDT,
'definition' => [
'map_name' => [
'type' => Cassandra\Type\Base::COLLECTION_MAP,
'value' => [
Cassandra\Type\Base::INT,
Cassandra\Type\Base::BOOLEAN
]
]
]
]])
which gives the error Caught exception: Since v0.7, collection types should have \"definition\" directive. I've also tried using 'definition' instead of 'value'. I'm running out of ideas, any help would be greatly appreciated.
Use "definition" instead of "value". I tried this before but apparently I was doing something else wrong because this worked.
new Cassandra\Type\CollectionSet($udt_array, [[
'type'=>Cassandra\Type\Base::UDT,
'definition' => [
'map_name' => [
'type' => Cassandra\Type\Base::COLLECTION_MAP,
'definition' => [
Cassandra\Type\Base::INT,
Cassandra\Type\Base::BOOLEAN
]
]
]
]])

MongoDB or operator for range

This is the range Im using :
$Range1=array('$or'=>array(
array( '$gte' => floatval($O_NLA), '$lte' => $N_NLA ),
array( '$gte' => floatval($N_SLA), '$lte' => $O_SLA ))
);
$Range2=array('$or'=>array(
array( '$gte' => floatval($N_SLO), '$lte' => $O_SLO ),
array( '$gte' => floatval($O_NLO), '$lte' => $N_NLO ))
);
A part of my query :
$finder=$reposit->findBy(
array(
'field1' => $Range1,
'field2' => $Range2,
'display'=>1
))->toArray();
"message":"localhost:27017: invalid operator: $or"..... (it's long though)
How can I use $or operator with doctrine without query builder?
findBy([
'$or' => [
['field1' => ['$gte' => floatval($O_NLA), '$lte' => $N_NLA]],
['field1' => ['$gte' => floatval($N_SLA), '$lte' => $O_SLA]],
['field2' => ['$gte' => floatval($N_SLO), '$lte' => $O_SLO]],
['field2' => ['$gte' => floatval($O_NLO), '$lte' => $N_NLO]]
]
, 'display' => 1
])
Or actually:
findBy([
'$and' => [
['$or' => [
['field1' => ['$gte' => floatval($O_NLA), '$lte' => $N_NLA]],
['field1' => ['$gte' => floatval($N_SLA), '$lte' => $O_SLA]],
]],
['$or' => [
['field2' => ['$gte' => floatval($N_SLO), '$lte' => $O_SLO]],
['field2' => ['$gte' => floatval($O_NLO), '$lte' => $N_NLO]]
]]
]
, 'display' => 1
])
To be more precise according to your question.
Since the $or works upon condition which then contains a find() like array.

Categories