Zend Gdata - setVisibility for newEventEntry? (specify events for multiple calendars) - php

I know that you can use setVisibility('private-abcdefg') for newEventQuery() in order to specify a particular calendar.
My question is, can I use the same concept for newEventEntry()?
$gdataCal = new Zend_Gdata_Calendar($client);
$newEvent = $gdataCal->newEventEntry();
$newEvent->setVisibility('private-******************');
I tried out this code, but I receive the error:
Fatal error: Call to a member function getDOM() on a non-object in /home/content/b/e/h/behrk2/html/ZendGdata-1.8.4PL1/library/Zend/Gdata/Kind/EventEntry.php on line 154
Is there anything I can do to accomplish this? Because I have multiple Google Calendar's in one account, and I would like to specify which Calendar an event should go to...
Thanks!

You're overthinking it. I had the same exact problem, and it's simple, but not obvious, and took me some digging through the documentation to notice. To post to a calendar other than the default calendar, just add the uri to the other calendar to the insertEvent function at the end, like so:
$createdEvent = $gdataCal->insertEvent($newEvent, $uri);

Related

Using WP_Session_Tokens class in a procedural WordPress Plugin

I'm writing a plugin for WordPress, in procedural PHP.
Anyway, in the plugin, I want to update a users WordPress Session Token, which is stored in the usermeta table.
Digging around, I've found a class which has some methods which I think will help me achieve my goal.
I've written a function, which has the correct data, updates the expiry time, and I'm just attempting to pass the update through WP_Session_Tokens.
But I get the error:
Using $this when not in object context in .../wp-includes/class-wp-session-tokens.php on line 166
My function is so:
function update_auth_cookie($user_login, $user) {
$options = get_option('options_premium');
$cookieTime = $options['cookieTime'];
$sessionToken = wp_get_session_token();
$verifier = hash('sha256', $sessionToken);
$sessions = get_user_meta($user->ID, 'session_tokens', true);
$sessions[$verifier]['expiration'] = $cookieTime;
WP_Session_Tokens::update( $verifier, $sessions[$verifier]);
}
add_action('auth_cookie_valid', 'update_auth_cookie', 10, 2);
Is it possible to access a class through a function like this? If so, is it obvious what I'm doing wrong?
Your question is a bit broad, since the problem you are experiencing is not really related to the issue you are trying to solve (and addressing it would not necessarily give you the solution for what you are trying to do).
But anyway: you are getting this error because you are invoking a method statically, and you should first instantiate WP_Session_Tokens and make the call dynamically.
This are basic OOP concepts you should be aware of before trying to use objects, and are not much more difficult than regular PHP syntax.
Something along the lines of:
$wp_session_token = WP_Session_Tokens::get_instance($user->ID);
$wp_session_token->update( $verifier, $sessions[$verifier]);
Word to the wise: I'm not 100% that the above will work, and I do not have a WP installation handy to test it out, but it is at least syntactically/semantically correct and wont give you the error you are experiencing above.

How to use findElements in Codeception using php

I have a page that contains a table with number of rows.
I need to work around a logic to which I need number of rows in that table
After searching in Google I found that findElements would do my work. When I tried this method I got a fatal error:
Fatal error:
Call to a member function findElements() on a non-object webDriver->findElements(\WebDriverBy::id("table-padding"));.
I just saw your question as I was looking for the same thing, I was able to do it in this way:
$I->executeInSelenium(function(\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver){ //Store current window id
global $meetings;
$meetings = $webdriver->findElements(WebDriverBy::cssselector('.today'));
});
I hope this can help you with your project.
It's much better to use $I->grabMultiple('.items', 'some_attribute')
https://codeception.com/docs/modules/PhpBrowser#grabMultiple
Another way is to use DOMDocument
$dom = new \DOMDocument();
#$dom->loadHTML($I->grabPageSource());
$xpath = new \DOMXPath($dom);
$elements = $xpath->query('.items');
$els = $this->getModule('WebDriver')->_findElements('.items');
_findElements
hidden API method, expected to be used from Helper classes
Locates element using available Codeception locator types:
XPath
CSS
Strict Locator
See more in docs

Google+ and googleCalendar API : Error "Cannot redeclare class Google_Acl"

I am using the google api php client.
Howewer, when I'm trying to include the three following libraries:
require_once app_path().'/library/googleapi/contrib/Google_PlusService.php';
require_once app_path().'/library/googleapi/contrib/Google_TasksService.php';
require_once app_path().'/library/googleapi/contrib/Google_CalendarService.php';
I get : Cannot redeclare class Google_Acl on line 784 of Google_CalendarService.php.
I know I could modify Google_CalendarService.php so that the class is only created if it doesn't exist, but this is kind of messy.
I need to load both libraries at the same time to create a valid AuthURL to authorize requests on google plus (to get the profile image) and the calendar (to get the calendar).
What's the best workaround for this ?
Seems that it is not possible to use these 3 libraries together
Reply from google code.google-api-php-client
Unfortunately its not the same object - there is name collision in
this version of the library. The alpha version 1.0.0 includes better
name generation that avoids this:
http://github.com/google/google-api-php-client/
The workaround at the moment is not to include both at the same time
unfortunately.
https://code.google.com/p/google-api-php-client/issues/detail?id=439

How to use extended properties with the Google Calendar php api

I have been struggling with the php api for Google Calendar for weeks now.
I have already managed to add and read events with the api and now I'm trying to get Extended Properies to work. I have tried two different ways of adding them to my events:
1:
$extProp = New Google_EventExtendedProperties('test', 'test');
$event->setExtendedProperty($extProps);
2:
$extProp = New Google_EventExtendedProperties('test', 'test');
$event->ExtendedProperty = $extProps;
Both don't give me errors, but I'm not sure if it's working. I tried to read the events with the get method as well as with the list method wich are both described in the documentation of the api, but I can't get my extended properties.
Does anyone know how extended properties work with php?
I finally managed to do it. I used the following code:
$extendedProperties = New Google_EventExtendedProperties();
$extendedProperties->setShared(array('custom'=>'blalblabla'));
$event->setExtendedProperties($extendedProperties);
$extendedProperties = New Google_EventExtendedProperties();
should be changed to:
$extendedProperties = new Google_Service_Calendar_EventExtendedProperties();

Calling web service (SOAP) with PHP involving enums

I wish to call a web service, using SOAP, from PHP (using the included SOAP extension). The web service in question is http://www.webservicex.net/CurrencyConvertor.asmx
Now the Currency type is an enum, and I cannot figure out how to work with these in PHP in order to be able to call the 'ConversionRate' function. I know I have to do something with a class map, but I can only find limited and unhelpful information on this topic. Can anyone help? A working example maybe?
Thanks!!!!
The enum here only defines legitimate values, that is your data type is actually a string of one of those values.
Here's some psuedo-code to get you on your way:
$from_currency = "AFA";
$to_current = "ALL";
$soap_handler->ConversionRate($from_currency, $to_currency);
$exchange_rate = $soap_handler->response();

Categories