Last active
January 2, 2016 11:49
-
-
Save krizon/8299508 to your computer and use it in GitHub Desktop.
See 1Question gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
Hi, | |
I'm working on a PHP client for the Google Measurement Protocol and building this based on Guzzle with service descriptions. I would like to know how to overwrite a required parameters through the client config. | |
The service definition can be found here: | |
https://github.com/krizon/php-ga-measurement-protocol/blob/tid-config/src/Krizon/Google/Analytics/MeasurementProtocol/Resources/service.php | |
As you can see the is the 'tid' parameter that needs to be send with every request. I would like to offer users two ways to pass the 'tid' parameter: | |
- as parameter, see parameter.php below, | |
OR | |
- as config value when creating the client, see config.php below; | |
It mostly works like expected but I want the 'tid' parameter to be required since it should included in every request. So i defined the 'tid' parameter to required but this results in an error when using the example of config.php. | |
To be more specific, this make the the test https://github.com/krizon/php-ga-measurement-protocol/blob/e3074b3af751ab4bad0f4cf9ee20dbc7db2afb8f/tests/Krizon/Google/Analytics/MeasurementProtocol/Test/MeasurementProtocolClientTest.php#L199 fail: | |
Guzzle\Service\Exception\ValidationException: Validation errors: [tid] is required; | |
How can one provide both ways to pass the 'tid' parameter and make the 'tid' parameter required? | |
Thanks! | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// See https://github.com/krizon/php-ga-measurement-protocol/blob/e3074b3af751ab4bad0f4cf9ee20dbc7db2afb8f/src/Krizon/Google/Analytics/MeasurementProtocol/MeasurementProtocolClient.php | |
$client = MeasurementProtocolClient::factory(array( | |
'tid' => 'XXXXXX' | |
)); | |
$client->pageview(array( | |
// ........ | |
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Nothing special about this | |
$client = MeasurementProtocolClient::factory(); | |
$client->pageview(array( | |
'tid' => 'XXXXXX' | |
// ........ | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment