Cannot get Oauth PHP extension to work - php

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.

Related

500 server error as soon as the namespace part of the docusign PHP SDK example is reached

I get a 500 server error when running the docusign php sdk example code.
I've ensured that I am using a PHP version above the required version. I am using PHP v 5.3.5, and the required version is 5.3.3. I have also ensured that curl and json are enabled. I have cut the example code listed on the github down to just these few lines, and still get the error. When I comment out the part that uses name spacing, the error stops occurring.
<?
require_once( 'includes/docusign-php-client-master/autoload.php' );
class DocuSign {
private $config;
public function __construct( $email, $password, $integratorKey ) {
// error happens on next line
$this->config = new DocuSign\eSign\Configuration();
}
}
$docusign = new DocuSign( $myemail, $mypassword, $myintegrationkey );
?>
I have replaced my actual email, pass, and key with variables. Any ideas as to why I am getting the error?
It turns out the required PHP version listed on the SDK is wrong. The SDK uses the array creation shorthand [], which requires PHP version 5.4 or higher.
In my experience, error 500 will often happen if newly uploaded files don't have the appropriate permissions on the server. Apply appropriate chmod permissions from the bash console (or FTP server) to allow Apache to read the files.

Phalcon Mongo Class not found error

I attempting to setup Phalcon PHP using a Mongo database connection. I have configured my bootstrap (index.php) file using the following:
// Mongo database connection
$di->set('mongo', function(){
$mongo = new Mongo();
return $mongo->selectDb("phalcon");
}, true);
// Collection Manager
$di->set('collectionManager', function(){
return new \Phalcon\Mvc\Collection\Manager();
});
Whenever I attempt execute an insert fucntion in using this connection, I receive a 500 Internal server error. Now, I have checked my apache server error logs and it states "PHP Fatal error: Class 'Mongo' not found in /var/www/phalcon-mongo/public/index.php on line 17".
I don't know why this request is not processing, according to the documentation given from Phalcon, the connection to mongo DB is setup up as I have displayed above.
If anyone has any advice, please let me know.
i think it's because your installation of Mongo is not valid.
try printing phpinfo() and check if mongo is loaded at all, if not - install it, add to ini files (if you use cli, don't forget to add to cli ini too) and reach the moment, when mongo is fully loaded.
try mongo w/o phalcon. any simple connection/insertation. you can see here: Fatal Error - 'Mongo' class not found that there are problems with apache module version for some people. Try reinstalling different mongo version.
if you can print this out:
echo Phalcon\Version::get();
there should be no problems with phalcon instalation
to validate mongo installation, try any of examples from php.net:
http://www.php.net/manual/en/mongo.tutorial.php
if both installations are valid, then there are problems with your custom code, but before doing anything you have to validate both installations.

Failed to create IO instance of Couchbase

I just change Couchbase 2.0beta for using Views.So,I follow the offical manual to build couchbase php extsion.
First,install a pure RHEL 6.2.Then,install couchbase-server-2.0.0-1723 and all dependent packages from libcouchbase:
libcouchbase2-dummy-2.0.0beta2-1.x86_64
couchbase-server-2.0.0-1723.x86_64
libcouchbase2-2.0.0beta2-1.x86_64
libcouchbase-devel-2.0.0beta2-1.x86_64
libev-4.03-3.el6.x86_64
libevent-1.4.13-1.el6.x86_64
Extract php-ext-couchbase-1.1.0-dp5-centos62-x86_64.tar.gz,copy couchbase.so to /usr/lib64/php/modules/,and edit /etc/php.d/json.ini:
extension=json.so
extension=couchbase.so
Finally,restart HTTP Server.Then,Check couchbase modules is lauch corrent by:
php -m|grep couchbase
and phpinfo() can output couchbase version is 1.1.0-dp5.
All looks well,but I try to run php code:
<?php
$cb = new Couchbase("127.0.0.1:8091",'Administrator','redflag','default');
$cb->set('a',1);
It's wrong:
$ php getview.php
PHP Warning: Couchbase::__construct(): failed to create IO instance in /var/www/html/getview.php on line 2
PHP Warning: Couchbase::set(): unintilized couchbase in /var/www/html/getview.php on line 3
In order to check couchbase setup is right,I open Couchbase GUI by Administrator as username,redflag as password.Then,create new document,use REST API get item or Views.Those things are OK,no problem,except php code.
No other way out,I git from https://github.com/couchbase/php-ext-couchbase. Build new php-couchbase extsion,and try agin.But the problem is the same.
I find someone has the same error on here & this.Unfortunately there was't solutions.
How can I use php-ext-couchbase 1.1dp5 modules?THX.
on a first glance it seems to load the couchbase extension properly. The thing that may be wrong here is how to access your bucket.
If you didn't do any changes, the "default" bucket has no password associated with it and in general the user of the bucket is the bucket name itself. So in the case of the "default" bucket, it would look like this:
$client = new Couchbase("127.0.0.1:8091", "default", "", "");
And if you have a password defined:
$client = new Couchbase("127.0.0.1:8091", "bucketname", "", "password");
Hope this helps,
Michael
Use yum to install libcouchbase2-libevent package can solve this problem.
BTW.While you run yum install libcouchbase-devel,it don't include libcouchbase2-libevent.If you miss that,you also can make & install php-ext-couchbase module with no error.But you can't connect Couchbase in php,as memtion above.

PHP OAUTH class api

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.

Php - Ingres, fresh install : How to debug?

I just finished to install Ingres on my server(only the client part, to connect to an existing ingres server), I just added the php_ingres module.
Now php recognize my module, so I tried to connect my self to several existing servers, but I always a
Unable to connect to database (Hostname here)
But with this I can't find what is wrong?? ingres error? Php driver? Credentials? ...?
What can I do to isolate these problem?
Most likely it's a user credentials issue. To see the actual error message use the following code:
$connection = ingres_connect(.....);
if (!is_resource($connection))
{
trigger_error(ingres_errno()." - ". ingres_error(),E_USER_ERROR);
}
You might also want to take a look at http://community.ingres.com/wiki/Ingres_with_Apache_on_Debian_Etch which outlines the setup steps for Ingres, PHP, Apache and Debian/Ubuntu.

Categories