I am using OAuth::fetch() example in PHP.net (Outh code. The cod i use is
<?PHP
try{
$oauth = new OAuth("consumer_key","consumer_secret",OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION);
$oauth->setToken("access_token","access_token_secret");
$oauth->fetch("http://photos.example.net/photo?file=vacation.jpg");
$response_info = $oauth->getLastResponseInfo();
header("Content-Type: {$response_info["content_type"]}");
echo $oauth->getLastResponse();
} catch(OAuthException $E) {
echo "Exception caught!\n";
}?>
The Error message is
Fatal error: Class 'OAuth' not found in C:\wamp\www\Jesvin\MyTest1\test1.php on line 3
You do not have the OAuth class available to use. It is a php extension and not part of the core package, you will need to install it manually into wamp. First thing to do is check whether the extension is available but not loaded.
Your php extension library will be something like /path/to/wamp/php/ext (i do not use wamp so you will have to google for your path or look for yourself in your filesystem).
If you see an oauth extension, you can skip installing oauth, if you do not you need to get a precompiled dll, look here: http://downloads.php.net/pierre/ and seach for "oauth", there are 2 (not sure which one you should use, so pick one, and if it doesnt work try the other).
Download it and stick teh dll in your extensions directory along with teh other php extensions.
Then find your php.ini file (you can use a file with <?php phpinfo; ?> and load it in your browser to see where php.ini is). Find where the extensions are defined and either uncomment or add this line to your php.ini file
extension=php_oauth.dll
ensure the dll name in the code above is teh same as the one you downloaded and installed to the extension folder. Also make sure there is NO semi colon at the start of this line.
That should just about do it. Hopefully php will load the DLL fine and it will work. Using pre-comiled dll's doesn't always work, but in this instance it will hopefully work.
Related
I installed the MongoDB PHP driver on Windows 10 (I'm using WAMP equipped with PHP 5.6.25. following the istructions I found at http://php.net/manual/en/mongodb.installation.windows.php and I installed also the libbson and libmongoc libraries (requested as requirements) as written at http://php.net/manual/en/mongodb.requirements.php.
Then, I added the bin folders of MongoDB, libbson and libmongoc to system path.
However, even if I can see the php_mongodb extension in the extensions list of WAMP, launching phpinfo() the mongo extension doesn't appear with the others.
Furthermore, tryng to connect to my database with
<?php
$mongo=new MongoClient("");
$db=$mongo->galileo;
$collection= $db->items;
print_r("Number of documens: "); ?>
I got the error
Fatal error: Class 'MongoClient' not found in C:\wamp64\www\galileo\index.php >on line 21
At a first look, reading this error, it might seem like that PHP is looking for php_mongodb extension in the uncorrect folder i.e. C:\wamp64\www\galileo\index.php (where the index page of my project is placed) instead of the correct one C:\wamp64\bin\php\php5.6.25\ext where all the extensions are.
But, looking at php log file php_error.log I find also a warning that says:
PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php5.6.25/ext/php_mongodb.dll' - Il sistema operativo non pu� eseguire %1.
in Unknown on line 0.
(for not Italian speaking, the phrase after - means the operating system can't execute %1, even if I can't imagine what %1 stands for).
Even using the new class MongoDB\Driver\Manager I get the error
Fatal error: Class 'MongoDB\Driver\Manager' not found in C:\wamp64\www\galileo\index.php on line 21
and the same warning.
Do you notice some error or forgetfulness in the installation process as I described and, if not, do you know how to fix the problem?
The problem is certainly related to WAMP and I think is related to the multiple php.ini in his folders. In fact, in the apache folder you can find a php.ini file that cannot be modified, otherwise nothing works at all; at the same time any changes made to the php.ini file in the php folder seems have no effect except making appear the mongodb extension in the extensions list.
So, I try using XAMPP, as suggested in this video tutorial and it works. Using Composer I was able to install also the PHP library and not only the driver.
you should not use 'MongoClient class' anymore, this extension that defines this class is deprecated. look at here.
instead, you should use MongoDB\Driver\Manager class. please read http://php.net/manual/en/class.mongodb-driver-manager.php.
and the setup must be like this in php:
$mongo = new MongoDB\Driver\Manager("mongodb://localhost:27017");
And if you still use the old class; you either need to install the old legacy extension (pecl install mongo) and use PHP 5.x, or update your code to use this new driver's classes as the old driver is not available for PHP 7. There is an upgrade guide at here.
the last part is from derickr's answer in this issue on github: https://github.com/mongodb/mongo-php-driver/issues/300
I''m pulling my hair out when trying to carry out an oAuth journey using PHP.
I'm using a MAC_OSX_10.7.4/MAMP/PHP and I am pointing to the php inside my MAMP environment.
I have downloaded the latest oAuth php extension 1.2.2.
I've run:
pecl install oauth
Which came back successful, when I try to reinstall it I get:
pecl/oauth is already installed and is the same as the released version 1.2.2
I have added the line:
extension=oauth.so
in my php.ini. but whenever I try and run this simple bit of code to test out oauth:
<?php
define("CONSUMER_KEY", "dgqcifzjqksh");
define("CONSUMER_SECRET", "73Ft6jKqe3A7sCsc");
$oauth = new OAuth(CONSUMER_KEY, CONSUMER_SECRET);
echo "oauth token" . $oauth;
$request_token_response = $oauth->getRequestToken('https://api.linkedin.com/uas/oauth/requestToken');
if($request_token_response === FALSE) {
throw new Exception("Failed fetching request token, response was: " . $oauth->getLastResponse());
} else {
$request_token = $request_token_response;
}
print "Request Token:\n";
printf(" - oauth_token = %s\n", $request_token['oauth_token']);
printf(" - oauth_token_secret = %s\n", $request_token['oauth_token_secret']);
print "\n";
?>
I get the following error in my php logs
PHP Fatal error: Class 'OAuth' not found in /Applications/MAMP/htdocs/wemustcreate/wp-content/themes/MinimalDessign/linkedinOauth.php on line 6
Any Ideas what I might be doing wrong? I've checked php.ini and it doesnt show up there. I have even removed existing extensions and re added them to make sure my php.ini was updated correctly.
The only thing I can see which stikes me as being slightly odd is that all my extensions ending with .so are all unix executable files but my oauth file is a document. could this be the problem? I have added a screenshot to show the extensions.
It happened with me that it is loaded in the php info page but not working.
Make sure what modules are really loaded, if "OAuth" is showing in the list:
php -m
Make sure that the extension file ".ini" is loaded in the right directory, in my case it was inside
/etc/php5/conf.d/
instead of where it is supposed to be:
/etc/php5/cli/conf.d/
Then restart apache.
I am trying to install xml diff ; https://github.com/mmacia/XMLdiff and i have not managed yet to make it work.Whenever i run any test example,i get
Fatal error: Interface 'PHPUnit_Framework_Test' not found in
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php on line 85
Has anyone managed to install and use the library.I am using xampp on windows.
I believe your problem has to do with PHPUnit's Autoloader.php not being included. This file sets the php spl_autoloadspl_register function which is responsible for loading in interfaces and classes like PHPUnit_Framework_Test.
According to this SO question, you have to include the autoloader file manually. Without knowing more about your set-up and how that particular library works, I would say do something like this in the appropriate file(s):
// define phpunit path
if ( ! defined('PHPUNIT_PATH')) {
// define an absolute path to your PHPUnit dir
// CHECK THIS, i'm not good with php on windows:
define('PHPUNIT_PATH','C:\xampp\php\PEAR\PHPUnit');
}
// Then include the autoloader like this:
include PHPUNIT_PATH.'Autoloader.php';
I hope this helps you or anyone else out.
Check execution flags for C:\xampp\php\PEAR\PHPUnit\Framework\Framework\Test.php
The file needs to be executable by the user who is launching tests (probably you).
I'm using PHPExcel to read data from a XLSX file. Everything works correctly on Debian & Apache, but it fails on IIS during the initial load:
$input = "C:/Inetpub/wwwroot/import/data/test.xlsx";
$objReader = new PHPExcel_Reader_Excel2007();
$objReader->setReadDataOnly(true);
print "Starting...";
try {
$objPHPExcel = $objReader->load($input);
print("Done!");
} catch (Exception $e) {
print "Caught exception: " . $e->getMessage();
}
Unfortunately there is no further output after "Starting..." although no errors are displayed nor tracked in the IIS logs. The file path is correct (tried both / and /) and has the proper permissions. Neither is an exception raised (tkx # Mark).
Please advise:
1) Is there a way to enable some sort of debugging to see where exactly PHPExcel stops and (maybe) why?
2) What do I need to change to have this code running on Windows & IIS.
Have you tried using XDebug? You will need an IDE like Netbeans or phpDesigner which supports it.
Then create project with all your files, open that file which does the reading and add a breakpoint at the first line of code that runs.
Start the debugger and step through each line until the error occurs and you might have a clue as to what's causing your problem. This will require lots of patience.
Good luck!
Try to make sure zip extension is enabled in php.ini:
extension=php_zip.dll
Still strange that no exception is thrown.
I had the same issue and resolved it by adding the following line:
PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);
Here is the explanation from the PHPExcel documentation: https://phpexcel.codeplex.com/wikipage?title=FAQ&referringTitle=Home
PHP complains about ZipArchive not being found
Make sure you meet all Requirements, especially php_zip extension
should be enabled. The ZipArchive class is only required when reading
or writing formats that use Zip compression (Excel2007 and OOCalc).
From version 1.7.6 the PCLZip library has been bundled with PHPExcel
as an alternative to the ZipArchive class. This can be enabled by
calling:
PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);
before calling the save method of the Excel2007 Writer. You can revert
to using ZipArchive by calling:
PHPExcel_Settings::setZipClass(PHPExcel_Settings::ZIPARCHIVE);
At present, this only allows you to write Excel2007 files without the
need for ZipArchive (not to read Excel2007 or OOCal)
I just try to integrate ImageMagick into my PHP project. I installed and just execute the sample files that they provided with the imagick-3.0.0RC1 zip file. But it shows
Fatal error: Class 'Imagick' not found in C:\wamp\www\imagick-3.0.0RC1\imagick-3.0.0RC1\examples\watermark.php on line 9
this kind of an error how can I avoid that. I cant see any class including section on that page. How to include the class files.
You need to install the ImageMagick PHP extension. According to the manual there is no prebuilt extension for Windows so you'll probably have to configure and compile it yourself.