I don't know if this has been asked before, but I'm trying to set up a simple call to the google API to retrieve events from a calendar (eventually i want to do more than this, but this is a test project to try to get up and running)
I have set up the project in the google developer pages and got the keys and secret etc, and enabled the calendar API
I have a folder on localhost, inside which is a single php file and the folder containing the library.
What I am currently getting is file not found errors, such as
failed to open stream: No such file or directory in ... google-api\src\Google\Client.php on line 18
What I don't understand is that this is one file in the library (Client.php) referencing another file (Google/Auth/AssertionCredentials.php) in the same library, so do I need to go through the entire library, editing all of the paths, or am i missing something? (or doing something really wrong?)
Many thanks,
John
As described in the installation documentation, you need to ensure that the /src folder is in your include_path. Alternatively, as you've found, you can just copy the /src/Google directory into the root of your application.
Related
I'm pretty new at this but I've been trying to use the google calendar API to show upcoming events on a website I'm making. So far I've enabled the API and created a service account to access the calendar. I've been using the instructions from another stackoverflow post but I keep getting an error. I believe this is the code that is causing it:
//set environment variable to use your downloaded Service account key
putenv("GOOGLE_APPLICATION_CREDENTIALS=myCredentials.json");
I have myCredentials.json in the same folder as the php file containing the above code. However when I test the code i get the following error:
Fatal error: Uncaught DomainException: Unable to read the credential file specified by GOOGLE_APPLICATION_CREDENTIALS: file myCredentials.json does not exist
I'm not sure if I should be placing myCredentials.json in a different location or did I not specify the path correctly?
Update: I fixed it by using an absolute path. In my case I just had to prepend /Applications/MAMP/htdocs/ since I was using MAMP.
You should specify the full path to the .json file when setting it as an environment variable.
You can verify that this is the problem by using getenv() function. You will notice the file is not found, but when you specify the absolute path it will find the file.
I'm following Braintree's instructions to create a client token using this page.
I made a Sandbox Account. Then, I downloaded the PHP library. The file downloaded as braintree-php-2.37.0.tgz, which I unzipped.
Then, using Eclipse for PHP Developers and following these directions, I:
went to Eclipse, then Preferences..., then PHP, then Libraries, then New...
made a new library called braintree
chose Add External folder... and added the braintree-php-2.37.0 folder which I had earlier unzipped.
went to the Properties of the app I'm working on
went to PHP, then Include Path, then Libraries, then Add Library...
then chose User Library and clicked Next >, then selected braintree (which I had just made) and clicked Finish
finalized by clicking OK
After I've done all of the above, I see that within the project's PHP Include Path folder, braintree is present with Braintree.php and all.
I then continued with the first set of instructions and my PHP file basically looks like this:
Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('<my_merchant_id>');
Braintree_Configuration::publicKey('<my_public_key>');
Braintree_Configuration::privateKey('<my_private_key>');
$clientToken = Braintree_ClientToken::generate();
But nothing happens. It seems like the code won't even get past Braintree_Configuration::environment('sandbox');.
I see in many places that require_once 'PATH_TO_BRAINTREE/lib/Braintree.php'; is included but I don't know how to write the path to the Braintree.php file. I added the actual path which leads to where I downloaded the Braintree folder, but that didn't help at all. And I'm also further confused because I figured that Braintree.php is already added as a library.
I'm also using Google App Engine and uploading my PHP code to their server. I'm not sure if this is part of the problem or not.
EDIT:
I took the unzipped folder (braintree-php-2.37.0) and copied it into the PHP folder so it could be uploaded to Google App Engine as well.
I then edited my PHP code to be this:
<?php
require_once('./braintree-php-2.37.0/lib/Braintree.php');
Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('<my_merchant_id>');
Braintree_Configuration::publicKey('<my_public_key>');
Braintree_Configuration::privateKey('<my_private_key>');
$clientToken = Braintree_ClientToken::generate();
?>
The code now won't get past require_once('./braintree-php-2.37.0/lib/Braintree.php');.
After discussing the details over with the staff from Braintree, we've come to the conclusion that, at the present moment, Google App Engine using PHP will not play nicely with Braintree's setup.
Hopefully there will be an answer to this problem in the future.
This is my first attempt at using a localhost while editing PHP website files (I'm a HTML girl, but have been asked to make some aesthetic changes to a PHP site).
I've installed XAMPP on my Mac already and configured it (as far as I know). MySQL Database, ProFTPD, and Apache Web Server are running. I've succeeded at viewing a simple index.php file from the htdocs files using localhost/index.php. I've placed the entire website directory (named newsite) inside the htdocs folder. When I attempt to view the website in Firefox or Safari via localhost/newsite/index.php I get this message in the browser:
Warning:
include_once(/Applications/XAMPP/xamppfiles/htdocs/inc/simplepie.inc):
failed to open stream: No such file or directory in
/Applications/XAMPP/xamppfiles/htdocs/newsite/index.php on line 2
This is referring to a block of PHP at the beginning of the index.php document. I've checked, the simplepie.inc file is in file inc under file newsite. If I try go around it by commenting out that section of code and any related calls, the browser goes blank. Can anyone please tell me what else I need to do to just view these files via localhost?
Okay, this is simple but might be complex. So you state:
I've checked, the simplepie.inc file is in file inc under file
newsite.
And then the error states:
Warning:
include_once(/Applications/XAMPP/xamppfiles/htdocs/inc/simplepie.inc):
failed to open stream: No such file or directory in
/Applications/XAMPP/xamppfiles/htdocs/newsite/index.php on line 2
So the error is being thrown because it is trying to read this file:
/Applications/XAMPP/xamppfiles/htdocs/inc/simplepie.inc
But it is located here:
/Applications/XAMPP/xamppfiles/htdocs/newsite/inc/simplepie.inc
What are the actual contents of that include_once?
Since you will probably be moving this site from one place to another, I recommend doing this. I am assuming I know what your include_once looks like, but the general concept holds true.
First, in your index.php or main config/init file (if you have one) add this line:
$BASE_PATH='/Applications/XAMPP/xamppfiles/htdocs/newsite';
Then for your include_once change it to read:
include_once($BASE_PATH . '/inc/simplepie.inc');
Basically that will do the equivalent of changing the include_once to this:
include_once('/Applications/XAMPP/xamppfiles/htdocs/newsite/inc/simplepie.inc');
But the flexibility of using $BASE_PATH is it allows you to change the general site $BASE_PATH in one place & then use it wherever in your site you wish.
I have cloned a git repo that someone made for a CodeIgniter website. I have a WAMP server set up fine in my computer and it works fine. In the Apache modules I enable the rewrite_module and in the PHP Settings I enable short open tag. I also put my database settings in the application\config\database.php file. After that, I put the CodeIgniter folder in the C:\wamp\www\CodeIgniter folder.
Now the problem is that when I go to localhost/CodeIgniter I get this:
Error: Template Directory Not Found!
I have looked for several hours online for this error but I could not find anything similar. If someone has seen this error before and knows how to solved it I will really appreciate any help or if you could point me in the right direction since I am new to CodeIgniter.
It sounds to me like your app is using a third-party Template library, and a config is incorrect
Search your application dir for "Template Directory Not Found" - that will take you to where the error message is in the code, and you can then figure out what library is calling it. Or, take a look in your application/config - most likely there's a file for it
"Template Directory Not Found" is not part of Codeigniter.
I've been trying to install jpgraph to my hostgator website but there's a problem somewhere which I can't figure out. There's a few things which are causing me to think the problem could be in several places;
first, when unpacking the file to my desktop ready to put into the server I get an error of 'The destination folder is a subfolder of the source folder', for this I just click continue and it seems to be OK.
This unpacks the folders which I rename to jpgraph as per the example FAQ on http://jpgraph.net/download/manuals/chunkhtml/ch02.html#id2475509
second, when I look at the examples the original code is [code]require_once ('jpgraph/jpgraph.php'); though the file structure is such that it should be jpgraph/src/jpgraph.php though even when I update the file structre the file doesn't work.
Third, I noticed when looking at different files some of the file structures reference jpgraph 3.xxx(version)/jpgraph.php but others use the short form jpgraph/jpgraph.php
I can't find any reasonable installation (see:Any) installation tutorials from youtube and the other thread on SO wasn't very helpful as it was solved in the background.
From your comment it looks like your php script just cannot find the jpgraph scripts, p.e. wrong path.
Try something like this, if you're using jpgraph as the graph lib of your choice:
$jpgraph_dir = '/your/path/to/your/jpgraph/';
require_once($jpgraph_dir . 'src/jpgraph.php');
If you still receive this error message, your path is just wrong.