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
Related
I have used composer to download the Angell EYE PayPal library into my vendor directory. Now I'm trying to call the class within a controller.
I've tried various methods:
Use \angelleye\PayPal;
at the top of page. I've tried using the require() method.
Within the controller I have used
$paypal = PayPal::PayPal($payment);
And a few other ways, but I just get the error Class not found at line 179 and I'm not sure why.
You just need to load a config file (depending on your framework) and the autoloader.
require_once('includes/config.php');
require_once('vendor/angelleye/paypal-php-library/autoload.php');
Of course, adjust the paths to suit where you have those saved, but the autoloader is what makes the classes available to you.
If you want more direct help you can submit a ticket here.
Thanks for response.
I actually managed to get it working on the framework.
I did nt have to load anything or require the class as the composer autoload must do it for me in the framework.
I simply added :
$PayPal = new \angelleye\PayPal\PayPal($PayPalConfig);
and it started to work.
Im guessing if i want to use the PayFlow i would call using:
$PayPal = new \angelleye\PayPal\PayFlow($PayPalConfig);
I will definately post back if the rest of the proccess fails to work.
I am trying to use the Parse.com SDK with PHP. I have downloaded and installed the SDK and I have successfully created a test object.
However, when trying to retrieve an object with a basic query using the sample code provided in the Parse docs and when I try to run it I get:
Fatal Error: Class 'ParseQuery' not found in /home/jameshilton/public_html/index.php on line 109
I would have guessed that it is not linking to the SDK properly but everything else is working fine.
Any ideas what I'm doing wrong?
By looking at the code of the class ParseClient in on GitHub I can see that the classes are declared in the namespace parse. So when you need an object from the Parse library you need to select the namespace. This can be done in two ways.
At the top of your file write:
use \parse;
or when instantiating the class:
$query = new \parse\ParseQuery
And remember to make sure the files are included either through an autoloader (composer?) or manually using include or require.
Regards.
guys, I am trying to use this new Facebook SDK for PHP to allow users to use their profiles on Facebook to login on my website
My website is using CodeIgniter, the PHP framework, but I couldn't make the FacebookSession class to load.
Am following this http://metah.ch/blog/2014/05/facebook-sdk-4-0-0-for-php-a-working-sample-to-get-started/ and this https://developers.facebook.com/docs/php/gettingstarted/4.0.0 tutorials
It keeps saying Fatal error: Class 'FacebookSession' not found and then I tried to move this code out of Code Igniter and yet I can't make it work
I started trying to use 'require_once' to import the class, but it also fails! This is all I have in one simple php file (2 lines):
require_once('src/Facebook/FacebookSession.php');
FacebookSession::setDefaultApplication('YOUR_APP_ID', 'YOUR_APP_SECRET');
It finds the file, presumably imports it (I put some 'echo' inside it and it prints the messages) but fails on the second line
I tried with the autoload.php that comes with the SDK, but it returns in the middle of the script in this condition:
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
// no, move to the next registered autoloader
return;
}
Why can't I import this file? It probably has something to do with namespaces, alias etc, right? So can you help me?
Your tutorial includes lines like this:
use Facebook\FacebookSession;
This allows you to use FacebookSession::something() instead of having to write out the full namespaced function Facebook\FacebookSession::something().
Add the use lines and things'll work.
Instead of this
FacebookSession::setDefaultApplication('YOUR_APP_ID', 'YOUR_APP_SECRET');
try this
Facebook\FacebookSession::setDefaultApplication('YOUR_APP_ID', 'YOUR_APP_SECRET');
if it works then use "Facebook\" as prefix with every Facebook class.
I've been using Couchbase for a large project where we only consume data, but have no requrirement to actually write to the Couchbase cluster. I want to write some management tools and be able to create Design Documents and Views through the API and not the web console.
Creating Documents is not an issue at all, but whenever I use setDesignDoc() I get the following error message:
Fatal error: Uncaught exception 'CouchbaseLibcouchbaseException' with message 'Failed to store design doc: Invalid input/arguments' in ....
I can get the actual view data from the source with getDesignDoc() and use it for the creating that design document on the destination server like so:
$connandleDestination->setDesignDoc( "myDesignDoc", $connSource->getDesignDoc("myDesignDoc") );
And that's where I get the above error message.
I'm using the PHP SDK by the way with the latest version against Couchbase 2.5.1
Can you confirm if what you've given as your example is the exact code you're using?
$connandleDestination->setDesignDoc( "myDesignDoc", $connSource->getDesignDoc("myDesignDoc") );
What you've given would not work as, from the API docs, the syntax is as follows:
setDesignDoc(string $name, string $document) : bool
Hence, it would appear you are trying to set a new doc, myDesignDoc to be equal to the design doc myDesignDoc, which would either not exist, or have no effect (as setting something to equal itself causes no change - and creating a new design doc with the name of an existing one will simply overwrite it).
Did you instead mean to just use get()? get() would return a document (which would be valid in the setDesignDoc input, and that document could have the same name as the new design doc to be created.
This is a continuation of my last question.
Hi,
I'm implementing, in a Symfony2 application, a custom authentication provider in order to authenticate against the Wordnik REST API.
On application load, no matter what request path, this is the exception I get:
( ! ) Fatal error: Cannot access parent:: when current class scope has no parent in /[..]/WordRot/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php on line 43
You can see the full stacktrace here.
Second to last line in the trace reveals that it is loading the DaoAuthenticationProvider:
18 0.0217 1922792 Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider->__construct( ) ../appDevDebugProjectContainer.php:3071
But none of my configuration refers to that provider, or anything that extends it. My custom provider directly implements the AuthenticationProviderInterface.
So I assume that my configuration is wrong, and somewhere I need to be explicitly setting the WordnikProvider, but I'm not sure where! Research has not provided any clues to this issue.
Any help would be much appreciated!
Files
/app/config/config.yml
/app/config/security.yml
/src/WordRot/PlayBundle/Security/Authentication/Provider/WordnikProvider.php
/src/WordRot/PlayBundle/Security/Authentication/Token/WordnikUserToken.php
/src/WordRot/PlayBundle/Security/Firewall/WordnikListener.php
/src/WordRot/PlayBundle/DependencyInjection/Security/Factory/WordnikFactory.php
the line return $this->authenticationManager->authenticate(new WordnikUserToken($username, $password, $this->providerKey)); in the WordnikListener goes to
Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager (classes.php)
authenticate.
$this->providers are DaoAuthentificationProvider, WordnikProvider and AnonymousAuthentificationProvider.
From the DaoAuthentificationProvider it only uses the method supports($token):
return $token instanceof UsernamePasswordToken && $this->providerKey === $token->getProviderKey();
which returns false so next in line is WordnikProvider.
Oh..misread: the error is in the constructor:
parent::__construct($userChecker, $providerKey, $hideUserNotFoundExceptions); seems to fail. Running PHP 5.4.10 or so I DON'T have an error!!
Either rm -rf vendor and run composer install again or try using a different PHP version!!
A had to create something like this a week ago.
At the and, I created a custom user provider, where I simply call the api and with the response i create the user or not.
I would advise to read this:
http://symfony.com/doc/2.0/cookbook/security/custom_provider.html