How can I use the newly revamped Dropbox-PHP API? - php

I would like to use the Dropbox-PHP API that has recently come under development again. It is located here: http://code.google.com/p/dropbox-php/
I did cloned it with hg clone https://dropbox-php.googlecode.com/hg/ dropbox-php and I get this file structure:
Dropbox/API.php
Dropbox/autoload.php
Dropbox/Exception/Forbidden.php
Dropbox/Exception/NotFound.php
Dropbox/Exception/OverQuota.php
Dropbox/Exception/RequestToken.php
Dropbox/Exception.php
Dropbox/OAuth/PEAR.php
Dropbox/OAuth/PHP.php
Dropbox/OAuth/Zend.php
Dropbox/OAuth.php
examples/accountinfo.php
examples/createaccount.php
examples/download_image.php
examples/getmetadata.php
examples/oauth_workflow.php
examples/uploading.php
But I get this error when trying to run accountinfo.php (or example):
Warning: include(Dropbox/autoload.php) [function.include]: failed to open stream
No such file or directory in dropbox-api/examples/accountinfo.php on line 7
Right, so then I move the Dropbox folder inside of where all the example files are and still get an error message:
Fatal error: Uncaught exception 'Dropbox_Exception' with message 'The OAuth class
could not be found! Did you install and enable the oauth extension?' in
examples/Dropbox/OAuth/PHP.php:36 Stack trace: #0 examples/accountinfo.php(9):
Dropbox_OAuth_PHP->__construct('', '') #1 {main} thrown in
examples/Dropbox/OAuth/PHP.php on line 36
So I'm obviously not doing something right but I have no idea what.
Also saw on the site where it has instructions on installing:
pear channel-discover pear.dropbox-php.com
pear install dropbox-php/Dropbox-alpha
I ran those two commands and it still won't work. I don't usually have any problems coding in PHP but the lack of documentation is a little frustrating.
Update
As noted in the accepted answer below my main problem was not having oAuth installed on the system. I'm running OS X 10.6 - if someone can provide some clear and easy instructions on how to build / install this to work with XAMPP / PHP 5.3 I will accept your answer. I've tried the articles online about using homebrew and such but these are flaky and do not seem to work for me. Guessing I will have to build / install it from scratch.

The Dropbox folder needs to be inside one of the folders in your include_path.
Edit:
Also oauth needs to be "installed" on the system and included in php.ini (when you do phpinfo() oAuth should show up as a module). then things should work.

Related

is this the right php header for pdftk

I'm writing a very basic catenation script and lifted this straight off the pdftk 0.10.0 packagist site:
use mikehaertl\pdftk\Pdf;
// Extract pages 1-2 into a new file
$pdf = new Pdf('sourcefile.pdf');
$result = $pdf->cat(1, 2)
->saveAs('newfile.pdf');
if ($result === false) {
$error = $pdf->getError();
}
But I'm getting this error:
Fatal error: Uncaught Error: Class "mikehaertl\pdftk\Pdf" not found in C:\PHP8\index.php:7 Stack trace: #0 {main} thrown in C:\PHP8\index.php on line 7
All the sample scripts I've seen have that same header. I'm sure it's something really basic that I'm not seeing here.
Since the error is showing the Class not found, it would make me initially think that the package wasn’t installed in your project. If you run composer require mikehaertl/php-pdftk, does that get you rolling?
If you’re not familiar with Composer, here’s a quick guide to getting started: https://packagist.org/
Apparently, when installed via composer, the pdftk.exe file is not downloaded for some reason. I downloaded it manually from the github page and referred to it in the header.
Ok, finally found the answer. You need to install pdftk beforehand as packagist does not automatically pull it for you.

installing Google Client Library for Google Analtics PHP

first of all I am new to this topic, so I hope my question is not too stupid.
I want my website to have PHP access to Google Analytics metrics. I followed every step of this description from google. Unfortunately when I upload everything on my server and try to run the test-site, I always get the following error-message:
Fatal error: Uncaught exception 'Exception' with message 'This library
must be installed via composer or by downloading the full package. See
the instructions at
https://github.com/google/google-api-php-client#installation.' in
/home/users/myftp/dev.mywebsite.com/dashboard/google-api-php-client-master/src/Google/autoload.php:14
Stack trace: #0
/home/users/myftp/dev.mywebsite.com/dashboard/HelloAnalytics.php(8):
require_once() #1
/home/users/myftp/dev.mywebsite.com/dashboard/HelloAnalytics.php(104):
getService() #2 {main} thrown in
/home/users/myftp/dev.mywebsite.com/dashboard/google-api-php-client-master/src/Google/autoload.php
on line 14
So apparently there is something wrong with the embedding of the Google client library. In the error message it says I have to use Composer, but in the GitHub documentation they say, manual download would be fine as well. I think in the end this shouldn't make any difference? I am not familiar with composer or GitHub, this is why i downloaded it manually.
I uploaded it on the server and put it into the same directory like the HelloAnalytics.php. I address it in HelloAnalytics.php via
require_once 'google-api-php-client-master/src/Google/autoload.php'
From the looks of it you are using the wrong autoloader.
src/Google/autoload.php looks for the composer autoloader and if it doesn't exist it throws the exception you are getting. Since you didn't install using Composer it is not found and that exception is thrown.
If you clone the repository using git you will have the correct SPL autoloader. If you download the package it uses the composer autoloader.
Try downloading using:
git clone -b v1-master https://github.com/google/google-api-php-client.git
Or switch to the v1-master branch and use this autoloader instead. You will see that file differs between the master branch and the v1-master branch.
to avoid AUTOLOADer error, install MASTER-V1 version:
https://github.com/google/google-api-php-client/tree/v1-master
p.s. if you will get other error, then ensure that you have correctly included the "SERVICE EMAIL" (that is like: xxxxxx#analytics-xxxxx.iam.gserviceaccount.com ).

Seemingly missing file when using JanRain OpenID PHP library with MySQL

I've just set up the JanRain OpenID library for PHP (https://github.com/openid/php-openid). I'm attempting to use the example server file, and the error I get is:
Warning: require_once(DB.php): failed to open stream: No such file or directory in /path/to/file/examples/server/config.php on line 28
I have searched the package and have not found any such file (DB.php). I do not see mention of it being generated. The config file I'm using was generated by the JanRain library's setup.php script.
Can anyone point me in the direction of what this file (which the library seems to expect) is and how I can obtain it?
DB.php is a part of pear DB package,
#pear install DB
for centos 6.x
#pear install DB-1.8.2
Thank for http://nobuneko.com/blog/archives/2016/01/php_533_pear_install_db_failed_php_540_higher.html

Failed opening required database.inc (attempting to use drupal)

I am trying to setup a drupal web server with FreeBSD.
When I try to access the drupal index i am greeted with:
Fatal error: require_once(): Failed opening required
'/usr/local/www/apache24/data/drupal/includes/database/sqlite/database.inc'
(include_path='.:/usr/local/share/pear') in
/usr/local/www/apache24/data/drupal/includes/database/database.inc on
line 1685
I am new to freeBSD but i tried setting chmod 667 to the:
sqlite/database.inc
database/database.inc
sqlite
database
Also, i do not understand why it is looking for /usr/local/share/pearas there is no such directory.
I am using MySQL55, PHP5, Drupal-7, and Apache.
I think this might be related but when i access the install.php i get:
Undefined index: distribution_name in drupal_install_profile_distribution_name() (line 201 of /usr/local/www/apache24/data/drupal/includes/install.inc).
did you use drush?
That looks as if you already installed drupal, or at least drupal thinks so. and also with the wrong database settings. normally, you will be prompted to enter them in the web interface, but you also can enter them directly in the settings php. Propably you should just move the old settings.php and run install.php in your browser and enter the database details anew.
drupal_install_profile_distribution_name can be changed in the database under system->standard_profile and variable->install_profiles directly or using drush (www.drush.ws) with
vset install_profile standard
or any other install profile you used.
Anyways, the install script asks for that as well.
hope, this was your problem.

PHP parser errors in Zend Framework

I just updated my project library folder (with an external to ZF svn) to ZF version 1.11. I'm now getting al kinds of weird errors, related to whitespaces, empty lines, etc. I searched on the internet for quite a while, but can't find a proper answer. I think this is related to some settings in my php.ini file but can't figure it out.
Example of an error:
Parse error: syntax error, unexpected $end in /library/Zend/Application.php on line 415 Call Stack: 0.0042 657160 1. {main}() /mnt/hgfs/htdocs/service/public/index.php:0
PHP version: PHP 5.3.5-0.dotdeb.1
All help would appreciated, I can't wrap my head around it!
I see you're running the project on a hgfs mount, probably inside your VM. Try to run your project off the hgfs mount as I found it to be buggy when dealing with these things.
For one, the default mount options don't keep into account that your file and directory properties (uid and gid) probably aren't the same on your guest and host system. Unfortunately, setting these right didn't fix it for me.
The solution I eventually used was to ditch the hgfs driver and mount the files using sshfs. On Debian you can just install it by running apt-get install sshfs. I then added an entry to /etc/fstab, like this:
sshfs#user#host:/path/to/host/dir /mnt/share fuse comment=sshfs,user,rw,exec,uid=1000,gid=1000,allow_other 0 0
Mounting the share can then be done by running this:
mount /mnt/share
Hope this helps!

Categories