I want to insert events in Google calendar through the API using a Symfony command (batch).
When I insert an event with an ID like "event01487", it throws me the following errors : "code": 400, "message": "Invalid resource id value."
This id is unique as no events have been inserted - it didn't even insert it once. The id seems to fit the Google requirements...
Do you have any idea why I got this ?
foreach($bookingsToSync as $booking){
$event = new Google_Service_Calendar_Event();
$event->setId($booking['id']);
$event->setSummary($booking['title']);
$event->setDescription($booking['description']);
$start = new \Google_Service_Calendar_EventDateTime();
$start->setDateTime($booking['startDate']->format(DateTime::ATOM));
$event->setStart($start);
$end = new \Google_Service_Calendar_EventDateTime();
$end->setDateTime($booking['endDate']->format(DateTime::ATOM));
$event->setEnd($end);
$output->writeln($event->getId());
$service->events->insert($calendarId, $event);
}
You have to follow the guidelines defined here : https://developers.google.com/google-apps/calendar/v3/reference/events/insert
Basically, the id has to be between 5 and 1024 characters and be composed from characters in this alphabet : 0123456789abcdefghijklmnopqrstuv
You should encode your id as base32
$encoded = bin2hex( $booking['id'] );
To Decode
$decoded = hex2bin( $encoded );
Related
I am relatively new to Microsoft Graph API. I am trying to extract a list of user profile information. When I run either of the following requests, I get a valid response:
Get displayname and birthday for single user:
GET https://graph.microsoft.com/v1.0/users/___userID___?$select=displayName,birthday
Get displayname for all users:
GET https://graph.microsoft.com/v1.0/users/?$select=displayName
However, when I try to run the following query, I receive an error:
Get displayname and birthday for all users:
GET https://graph.microsoft.com/v1.0/users/?$select=displayName,birthday
The error I receive is as follows:
{
"error": {
"code": "UnknownError",
"message": "",
"innerError": {
"date": "2023-02-02T05:57:08",
"request-id": "e8ae37af-3478-4446-a328-9d79f7aac0fc",
"client-request-id": "a667c3f1-0183-3382-c601-2197456a758d"
}
}
}
This error seems to occur with only some attribute types, forexample hiredate and birthday. If I query for displayname and userprincipalname, I do get the same error.
I would appreciate any suggestions.
For anyone reading this in the future, I was able to achieve my desired outcome using the following script.
Thanks to user2250152's answer, I realized I could not query for the necessary properties in bulk. So I used PowerShell to first pull a list of all users, and then loop through each of them to query the required properties.
# Report on User Profiles in SPO
# Define attributes to query
$attributes = #("displayname","aboutMe","skills","interests","birthday","hireDate")
# Connect to Graph
Connect-MgGraph -Scopes "User.Read.All"
Select-MgProfile -Name beta
# Get list of active users
$users = Get-MgUser -All | Where-Object {($_.AccountEnabled -eq $true) -and ($_.OnPremisesSyncEnabled -eq $true) -and ($_.UserType -eq "Member")}
# Loop through all users and query for SPO profile attributes
$results = #()
foreach ($user in $users) {
$query = Get-MgUser -UserID $user.Id -Select $attributes | Select-Object $attributes
$results += $query
}
# Display Results
$results | Out-GridView
According to the documentation, properties aboutMe, birthday, hireDate, interests, mySite, pastProjects, preferredName, responsibilities, schools, skills, mailboxSettings cannot be returned within a user collection.
They are only supported when retrieving a single user.
I am trying to create a node in Google Firebase, and use its unique id to create a Document in Google Firestore of the same name.
I'm using Google's PHP Firestore Client: https://github.com/GoogleCloudPlatform/google-cloud-php-firestore
And I've read through their documentation: http://googlecloudplatform.github.io/google-cloud-php/#/docs/cloud-firestore/v0.5.1/firestore/writebatch
Here is my code:
<?php
use \Google\Cloud\Firestore\FirestoreClient;
use \Google\Cloud\Core\Timestamp;
use \Google\Cloud\Firestore\Transaction as FirestoreTransaction;
use \grptx\Firebase as FirebaseClient;
class FirestoreTest
{
public function create()
{
$client = new FirebaseClient();
$database = $client->getDatabase();
$org = array(
"acl" => array(),
"people" => array()
);
$ref = $database->getReference("/clients/")->push($org);
$key = $ref->getKey();
$config = array(
"projectId" => "xxx",
"keyFile" => json_decode(file_get_contents("/xxx/firebase_auth.json"), true)
);
$firestore = new FirestoreClient($config);
$batch = $firestore->batch();
$collection = $firestore->collection("clients")->document("-LXXXXXX")->collection("trips");
}
}
And I get this error:
Exception 'Google\Cloud\Core\Exception\BadRequestException' with message '{
"message": "Document name \"projects\/xxx-test\/databases\/(default)\/documents\/clients\/\" has invalid trailing \"\/\".",
"code": 3,
"status": "INVALID_ARGUMENT",
"details": []
}'
Any help is appreciated.
Basically this will happen if you try to put blank as document name.
This is the error that occurs if you try to get a collection as a document. It's kind of tricky because this can also happen if you try to get a document with the name of empty string in a collection.
I don't know PHP, but I would guess that either in your $database->getReference("/clients/")->push($org); call, you were supposed to name a document to push your information to, or in your $firestore->collection("clients")->document("-LXXXXXX")->collection("trips"); call that the document you are trying to get ("-LXXXXXX") has the name empty string. (Of course, this is assuming your document isn't actually named "-LXXXXXX", and you are using that as a substitute for some variable that happens to be equal to "").
For instance, in python this call randomly failed me earlier:
db.collection(u'data').document(current_id)
with the same error: 'Document name ".../documents/data/" has invalid trailing "/". and will exit.' I scratched my head for a while but that's because the variable current_id is the empty string.
Basically, internally Firebase converts it into a long pathname and then tries to get a document or a collection at that pathname depending on what your last call was. This causes an issue if you try to get a document that is named "".
Goog day. When I try to get custom dimensions via API, I got error
Exception 'Google_Service_Exception' with message 'Error calling GET
https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/customDimensions:
(400) Cannot query by ~all for id webPropertyId'
My code
$service_account_name = '<Service Email>#developer.gserviceaccount.com';
$key_file_location = '<keyName>.p12';
$key = file_get_contents($key_file_location);
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
array(Google_Service_Analytics::ANALYTICS),
$key,
'notasecret',
'http://oauth.net/grant_type/jwt/1.0/bearer',
'<My email>'
);
$client->getAuth()->setAssertionCredentials($cred);
$service = new Google_Service_Analytics($client);
$result = $service->management_customDimensions->listManagementCustomDimensions('~all', '~all');
print_r($result);
Similar code for getting goals works correctly
$service_account_name = '<Service Email>#developer.gserviceaccount.com';
$key_file_location = '<keyName>.p12';
$key = file_get_contents($key_file_location);
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
array(Google_Service_Analytics::ANALYTICS),
$key,
'notasecret',
'http://oauth.net/grant_type/jwt/1.0/bearer',
'<My email>'
);
$client->getAuth()->setAssertionCredentials($cred);
$service = new Google_Service_Analytics($client);
$result = $service->management_profiles->listManagementProfiles('~all', '~all');
print_r($result);
Both methods listManagementProfiles and listManagementProfiles get parametrs $accountId and $webPropertyId .
Could someone help, why I get error, while getting custom dimensions via API?
Looking at the documentation "~all" is specifically mentioned as valid parameter value for listManagementProfiles:
Account ID for the view (profiles) to retrieve. Can either be a
specific account ID or '~all', which refers to all the accounts to
which the user has access.
but not for listManagementCustomDimensions, here is says simply
Account ID for the custom dimensions to retrieve.
(same for property id). So your problem is quite literally what the error message says, you cannot use "~all" when querying custom dimensions.
So it seems that to list all custom dimensions you'd have to iterate through a list of property ids (as returned by the properties/list method) instead of using "~all".
I'm currently doing this tutorial: http://tutorial.symblog.co.uk/docs/testing-unit-and-functional-phpunit.html I'm at the "Test contact page" part.
There we have defined a test called testContact() http://pastebin.com/PtzwY7PJ (edited by me, the outcommented stuff results in the same error)
If I run the tests I get the error. InvalidArgumentException: Unreachable field "name"
If I send the form on the page I can catch if via the symfony toolbar, so I assume, the form works correctly.
Heres the dumped object of $form: http://pastebin.com/n8MyHEfy
Thanks!
the form is named 'contact' now, so you need:
// Select based on button value, or id or name for buttons
$form = $crawler->selectButton('Submit')->form();
$form['contact[name]'] = 'name';
$form['contact[email]'] = 'email#email.com';
$form['contact[subject]'] = 'Subject';
$form['contact[body]'] = 'The comment body must be at least 50 characters long as there is a validation constrain on the Enquiry entity';
$crawler = $client->submit($form);
shouldn't it be like this?
$form = $crawler->selectButton('Submit')->form(array(
'blogger_blogbundle_enquirytype[name]' =>'name'
));
I am trying to get amazon payments working w/ my flex app, as shown here:
http://miti.pricope.com/2009/07/11/using-amazon-flexible-payment-system-with-flex/
I've done exactly as he says, I've downloaded the files & changed the access key & secret key. When I run it on localhost or my production server I get "Signature did not match"
What else do I need to get this to work? Is there something else I need that he forgot to include.?
Lets try next:
goto return.and find function validateQueryString() and change to this:
function validateQueryString()
{
echo "validing the query string now\n";
$querystring = $_SERVER['QUERY_STRING'];
echo $querystring."\n";
echo $_GET['signature'];
$obj = new Amazon_FPS_CBUIUtils(AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY);
//Original signature received in response from Amazon FPS should be specified.
$signatureMatched = $obj->validateQueryString($querystring,$_GET['signature']);
if ($signatureMatched) {
echo "signature matched \n";
$request = new Amazon_FPS_Model_PayRequest();
//set the proper senderToken here.
$request->setSenderTokenId($_GET['tokenID']);
$amount = new Amazon_FPS_Model_Amount();
$amount->setCurrencyCode("USD");
//set the transaction amount here;
$amount->setValue($_SESSION['transaction_amount']);
$request->setTransactionAmount($amount);
//set the unique caller reference here.
$request->setCallerReference($_GET['callerReference']);
$service = new Amazon_FPS_Client(AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY);
invokePay($service, $request);
}
else
echo "Signature did not match \n";
}
and post output here please, including your Signature did not match
Thanks.