Google Calendar - trouble with setting Google_EventReminders - php

I am trying to set a reminder in a calendar using the Google PHP libraries with this code:
$rem = new Google_EventReminders();
$rem->setUseDefault('false');
$overrides = array("method"=> "popup","minutes" => "15");
$rem->setOverrides($overrides);
$event->setReminders($rem);
The event I am sending to the API contains the following data:
[reminders] => Google_EventReminders Object
(
[__overridesType:protected] => Google_EventReminder
[__overridesDataType:protected] => array
[overrides] => Array
(
[method] => popup
[minutes] => 15
)
[useDefault] => false
)
But the event itself does not appear in my calendar with a reminder.
Any pointers on what I'm doing wrong v.gratefully received. Thank you, Tony

You have to pass an array of reminders in the setReminders method, as in this example:
<?php
$reminder = new Google_EventReminders();
$reminder->setUseDefault(false);
$overrides = array("method"=> "popup","minutes" => "15");
$reminder->setOverrides(array($overrides));
$event->setReminders($reminder);
?>
In Google_EventReminders class, the method setOverrides only accepts an array of reminders to validate these settings (by the method assertIsArray), as shown below:
<?php
public function setOverrides(/* array(Google_EventReminder) */ $overrides) {
$this->assertIsArray($overrides, 'Google_EventReminder', __METHOD__);
$this->overrides = $overrides;
}
?>

Related

Google cloud -speech api return null result

I work with Google cloud speech API. When I run my script there is a call to the API and a response. The operation info returns data, but the result is empty.
Here is my code (where file url, file name, key url, project name and bucket name I deleted the real data):
function __construct(){
$file_url='file path.mp3';
$filename='file name.mp3';
/** Create google client **/
$client = new Google_Client();
$key='path to google key';
putenv($key);
$client->useApplicationDefaultCredentials();
/** Create storage **/
$str_config = array(
'projectId' => 'project id'
);
$storage = new StorageClient($str_config);
$bucket_name='bucket name';
$bucket=$storage->bucket($bucket_name);
$object = $bucket->object($filename);
/** Create Speech **/
$config = array(
'projectId' => 'project id',
'languageCode' => 'en-US'
);
$options = array(
"encoding"=>'LINEAR16',
"languageCode"=>"en-US",
'sampleRateHertz' => 16000
)
;
$speech = new Google\Cloud\Speech\SpeechClient($config);
$operation = $speech->beginRecognizeOperation(
$object,
$options
);
$backoff = new ExponentialBackoff(100);
$backoff->execute(function () use ($operation) {
print('Waiting for operation to complete' . PHP_EOL);
$operation->reload();
if (!$operation->isComplete()) {
throw new Exception('Job has not yet completed', 500);
}
});
if ($operation->isComplete()) {
if (empty($results = $operation->results())) {
$results = $operation->info();
}
var_dump($results, $operatimon->results());
}
}
The result i get call:
Array
(
[0] => Array
(
[name] => some name
[metadata] => Array
(
[#type]=> type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeMetadata
[progressPercent] => 100
[startTime] => 2017-07-16T19:15:58.768490Z
[lastUpdateTime] => 2017-07-16T19:15:59.999625Z
)
[done] => 1
[response] => Array
(
[#type]=> type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeResponse
[totalBilledTime] => 15s
)
)
[1] => Array
(
)
)
I tried several file type whit several encodings, can't find the right combination. Or maybe there is another problem. Pleas Help.
Solved it by using the ffmpeg library to encode the audio to flac whit mono channel.
For anyone else encountering this problem, the issue could lie in your audio file not matching the encoding you've entered in your option array.
Check this resource:
https://cloud.google.com/speech-to-text/docs/reference/rest/v1beta1/RecognitionConfig#AudioEncoding
Just like the accepted answer, by changing from "LINEAR16" to "FLAC" and converting my audio file to FLAC, it worked for me.

cvent soap api error (php)

I'm trying to use php to get access to the Cvent soap API to display a list of upcoming events. I found this: https://github.com/gcanivet/php-cvent
I'm getting "INVALID_CVENT_HEADER_VALUE" when it comes to this function:
public function SearchByFilter($objecttype, $type, $filters){
$response = $this->client->Search((object) array('ObjectType' => $objecttype, 'CvSearchObject' => (object) array('SearchType' => $type, 'Filter' => $filters)));
return $response;
}
I've echoed out what's being sent to that function:
$objecttype = 'Event';
$type = 'AndSearch';
$filters =
Array
(
[0] => stdClass Object
(
[Field] => EventStartDate
[Operator] => Greater than
[Value] => 2016-11-28T00:00:00
)
)
All I've done is save the file, add my credentials and attempted to echo out $events
$account = /* my account */
$username = /* my username */
$password = /* my password */
require('/templates/home/assets/CventClient.class.php');
$cc = new CventClient();
$cc->Login($account,$username,$password);
$events = $cc->GetUpcomingEvents();
I've found this documentation https://custom.cvent.com/5A44061C587B4DF999B70EC98DCA9A84/files/eb1d01535a124863a290b36fa4cd8bd3.pdf but I'm not sure what's wrong, or why it's not working. I have had no experience with SOAP whatsoever. Any help would be greatly appreciated!!
The returned result when you var_dump($event) is the keys of the event. To get the title of the event you have to get the eventId.
`require('/templates/home/assets/CventClient.class.php');
$cc = new CventClient();
$cc->Login($account,$username,$password);
$events = $cc->GetUpcomingEvents();
foreach($events as $event)
{
$response = $cc->GetEventById($event);
//This retrieves the title of all events
$eventsTitle = $response->EventTitle;
var_dump($eventsTitle );
}`

Unable to get data from aws sns email bounce notification message

I have subscribed my endpoint and now I need to pull the emailAddress from the object/array I cannot get the value 'fakeemail#
gmail.com' for the life of me
Aws\Sns\Message Object
(
data:Aws\Sns\Message:private => Array
(
Type => Notification
MessageId => hghkvvhhv32hg32vh23v32hjk32bjk
TopicArn => arn:aws:sns:us-west-232jh32bhj322j3hv23jhv23jhv2
Message => {"notificationType":"Bounce","bounce":{"bounceType":"Permanent","bounceSubType":"Suppressed","bouncedRecipients":,"timestamp":"2016-06-21T04:43:05.786Z","feedbackId":"wef-a5166c3e-fe-11e6-923e4-1115qbdde1aq2907d-000000","reportingMTA":"dns; amazonses.com"},"mail":{"timestamp":"2016-06-21T04:43:04.000Z","source":"www-data#myserver.com","sourceArn":"arn:aws:ses:us-west-2:0f2243234320627162:identity/myserver.com","sendingAccountId":"0243122452162","messageId":"0103714433d74e-e3bfd2dd3b3b7-49238-45a3f-953fa-c9a3eb3fd312c-03300000","destination":["fakeemail#
gmail.com"]}}
Timestamp => 2016-06-21T04:43:05.882Z
SignatureVersion => 1
Signature => vfvdfvsdffsvfadvfdvdfvdfdfsdvsdfdf
SigningCertURL => https://sns.us-west-2.amazonaws.com/SimpleNotificationService-vafvadfvadsvdsfdsvsvdsdfsdvsdsvd.pem
UnsubscribeURL => https://sns.us-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-west-2:02vsddfvddv43230vfvsvf67162:email_bounce:5fc6vsdfvd6af9-cfssdvdv197-4vfsdf0f-afb7-67fvdfs1b
)
)
I have changed my details above but this is what is given. I need to get the
fakeemail#gmail.com from array in the object but cant for the life of me
//from aws sdk
$message = Message::fromRawPostData();
I used
print_r($message['Message'], true);
to get the data above would be appreciated :)
Ok I figured it out. You want to take the
$message['Message']
and encode it to json to use as an object
$test = json_decode($message['Message']);
$returnsMyAnswer = print_r($test-> mail-> destination[0], true);
and then
echo $returnsMyAnswer;
and you get
fakeemail# gmail.com

Twitter OAuth: users/search works but search/tweets does not

I want search for tweets in twitter. It is not working.
$parameters = array('q' => 'oauth');
$result = $connection->get('search', $parameters);
But when I do a user search it working perfectly.
$parameters = array('q' => 'oauth');
$result = $connection->get('users/search', $parameters);
I have also tried the below and that is also not working
$parameters = array('q' => 'oauth');
$result = $connection->get('search/tweets', $parameters);
What could be the reason?
Error message
stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[message] => Sorry, that page does not exist
[code] => 34
)
)
)
You seem to be using the library TwitterOAuth by Abraham Williams.
I know this is an old question but I have just had the same problem as OP and it might keep happening to anyone else since apparently this library has not been updated for a while.
The problem seems to be that Twitter is no longer accepting requests via the version 1 of their API. You have to change the $host variable in the file twitteroauth.php as follows:
/* Set up the API root URL. */
//public $host = "https://api.twitter.com/1/";
public $host = "https://api.twitter.com/1.1/";

Salesforce PHP SOAP API - Unable to get custom WebService working

Let me set the scene:
I'm a PHP developer that needs to take info from a web form and send it into a clients Salesforce. At first I though it was as simple as using Web2Lead. However the client has a Salesforce developer in house.
The in house developer has sent me partner.wsdl and CatalystWebservice.wsdl files along with login details to their sandbox to run all this on. The in house developer has basically said I need to use the SOAP API of Salesforce and once connected and logged in I need to call ->makeContact("FormField1", "FormField2", "etc...");
So after spending all day trying many things and hitting many problems I have finally hit a wall I cannot climb. Here is my PHP code I have now:
<pre>
<?php
define("SOAP_CLIENT_BASEDIR", "../soapclient");
$USERNAME = '******#********' ;
$PASSWORD = '******************************' ;
require_once (SOAP_CLIENT_BASEDIR.'/SforcePartnerClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');
try {
$mySforceConnection = new SforcePartnerClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/partner2.wsdl.xml');
$loginResult = $mySforceConnection->login($USERNAME, $PASSWORD);
$location = $mySforceConnection->getLocation();
$session_ID = $mySforceConnection->getSessionId();
$client = new SoapClient(SOAP_CLIENT_BASEDIR.'/CatalystWebservice.wsdl.xml');
$sforce_header = new SoapHeader("http://soap.sforce.com/schemas/class/CatalystWebservice", "SessionHeader", array( "sessionId" => $session_ID ) );
$client->__setSoapHeaders( array( $sforce_header ) );
$client->makeContact("*****", "*****", "Address1", "Address2", "London", "****", "no-one#****", "0123456789", "07891236456", "New Build Homebuy", "This is my question\n\nAnd an other line", "1", "Test");
} catch (Exception $e) {
print_r($e);
}
?>
</pre>
I have starred out sensitive information for here. When I run the above code I get the following output:
SoapFault Object
(
[message:protected] => UNKNOWN_EXCEPTION: An unexpected error occurred. Please include this ErrorId if you contact support: ***********-*** (***********)
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /home/******/public_html/********/test/partner.php
[line:protected] => 23
[trace:Exception:private] => Array
(
[0] => Array
.....
And the CatalystWebservice.wsdl.xml file
The in house developer has developed something in C# to test his WebService and it works perfectly fine so it must be something I am not doing right. What am I doing incorrectly?
I found the solution... I had to make sure I was sending the data as an associative array like so:
$response = $client->makeContact
(
array
(
"sLastName" => (string) $wpcf7_data->posted_data['last-name'],
"sFirstName" => (string) $wpcf7_data->posted_data['first-name'],
"sAddress1" => (string) $wpcf7_data->posted_data['address-one'],
"sAddress2" => (string) $wpcf7_data->posted_data['address-two'],
"sCity" => (string) $wpcf7_data->posted_data['town-city'],
"sPostcode" => (string) $wpcf7_data->posted_data['post-code'],
"sEmail" => (string) $wpcf7_data->posted_data['email-address'],
"sPhone" => (string) $wpcf7_data->posted_data['telephone'],
"sMobile" => (string) "",
"sEnquiries" => (string) $wpcf7_data->posted_data['enquiry'],
"sComment" => (string) $wpcf7_data->posted_data['comments'],
"sPropertyID" => (string) wpcf7_special_mail_tag_for_post_data( "", "_post_id" ),
"sPropertyName" => (string) wpcf7_special_mail_tag_for_post_data( "", "_post_title" ),
)
);

Categories