I get an Exception on my production server when i try to instanciate the class "OAuthProvider" from pecl package oauth.
try {
$oauth = new OAuthProvider();
} catch(Exception $e) {
// Get the error here
}
The error message is : "Unknown signature method"
Have anyone got this error ?
OAuthProvider looks for the oauth_signature_method in either the Authorization header or REQUEST params (respectively) if you run a non-CLI SAPI.
Under the CLI SAPI you can set the parameters in the ctor:
$op = new OAuthProvider(array("oauth_signature_method" => OAUTH_SIG_METHOD_HMACSHA1));
This is PHP bug #68168 - some servers have an empty $_SERVER[HTTP_AUTHORIZATION] value, which is not correctly detected by the php oauth extension.
Related
How do you catch errors thrown by the HTTP client (for example a time out) so that it doesn't throw the curl error in the Laraval debugger (in debug mode) before you can do anything with the error to avoid stopping the execution?
use Illuminate\Support\Facades\Http;
try {
$request = Http::post('https://example.com/post', [
'password' => 'guest']);
} catch(ConnectException $e)
{
//log error
}
//continue with another mode
Instead, I'm always getting the Laravel's Ignition error page
Illuminate\Http\Client\ConnectionException
cURL error 28: Failed to connect to example.com port 443: Timed out
and the error is not caught by my code. Is it possible that the laravel debugger always have priority and can't be overridden in debug mode?
This is almost certainly a namespacing issue.
You'll need either this at the top of the file:
use Illuminate\Http\Client\ConnectionException;
or do this:
} catch(\Illuminate\Http\Client\ConnectionException $e)
Otherwise, you're actually trying to catch something in the current namespace named ConnectionException (i.e. something like App\Controllers\ConnectionException), which will never exist.
I am trying to do a very simple integration with the Salesforce PHP Toolkit 20.0. Everything works fine on my local server so I think it must be a server setting, but I don't see any issues with my server configuration. Additionally, the errors I'm getting aren't helping at all.
I've removed the actual authentication piece because I'm getting errors just running the basic createConnection function. Here is the code:
define("SOAP_CLIENT_BASEDIR", "soapclient");
require_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php');
try {
$mySforceConnection = new SforceEnterpriseClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
}
catch (Exception $e) {
exit($e->faultstring);
}
Running that code alone, I get the following error:
<br />
<b>Fatal error</b>: SoapClient::__setSoapHeaders(): Invalid SOAP header in <b>/home/website/public_html/app/equity/soapclient/SforceBaseClient.php</b> on line <b>325</b><br />
My server is running PHP 5.6 and OpenSSL, SOAP, SSL, and cURL is enabled.
I have no idea why, but changing my Salesforce password fixed the issue.
I'm building an application with ZF2.
I use ajax to POST some data on the application and when I trhrow a new Exception with this line:
throw new \Exception("Not Loged In.", 401);
The problem is everytime I throw a new error it returns a 500 even if I put anything as a second parameter of the exception.
Can anyone help me?
Thanks!
From zend framework's request lifecycle perspective every uncaught exception is an application error. You need a mechanism to convert that exceptions to meaningful HTTP responses before the framework convert them to an HTTP 50X for you.
For example, in your controller you can try something like below:
try {
$this->myService->tryToDoSomethingThatNeedsAuthentication();
} catch(AuthRequiredException $e) {
$this->getResponse()->setStatusCode($e->getCode()) // Assuming its 401
->setReasonPhrase($e->getMessage());
return;
} catch(\Exception) {
// handle other exceptions here
}
Problem is in your php configuration. Default Apache (or other server) hide details of your internal errors, so is returned short info:
Error 500 - internal server error
You must enable error_reporting:
in PHP:
http://php.net/manual/pl/function.error-reporting.php
or in php.ini in Apache configuration, and in .htaccess file it's possible. For developer's work you should show all errors.
I use Redis as session storage in my website (Laravel 4.2). Sometimes I get following errors. I guess ">" char broke the setex commands.
production.ERROR: exception 'Predis\ServerException' with message 'ERR unknown command '>'' in
production.ERROR: exception 'Predis\ServerException' with message 'ERR unknown command 'tml>''
production.ERROR: exception 'Predis\ServerException' with message 'ERR unknown command '</div>''
These errors occurs rarely on production server and I can't reproduce them. Do you have any idea why these errors occurs and how can I prevent them?
key: laravel:xxxxxxxxxxxxxxx
value: s:217:"a:4:{s:6:"_token";s:40:"xxxxxxxxxxx";s:4:"lang";s:2:"fr";s:9:"_sf2_meta";a:3:{s:1:"u";i:1461777248;s:1:"c";i:1461777248;s:1:"l";s:1:"0";}s:5:"flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}";
exception 'Predis\ServerException' with message 'ERR unknown command 'ml>'' in vendor/predis/predis/lib/Predis/Client.php:282
Update
Code example where I am using redis.
public function view($username = null)
{
$username = mb_strtolower($username);
$redis = $this->getRedis();
try{
$view = $redis->get(User::getCacheKeyByUsername($username));
}catch (\Exception $exception){
$view = null;
}
if($view === null || Session::has("admin")){
$user = User::where('username', '=', $username)->where("status", 1)->first();
if (empty($user)) {
return Redirect::to(Session::get("lang") . '/all');
}
$view = View::make("view", array("user" => $user));
if(!Session::has("admin")){
try{
$redis->setex(User::getCacheKeyByUsername($username), 3600, $view);
}catch (\Exception $exception){
Log::error($exception->getMessage());
}
}
}
return $view;
}
Ok, so basically what can I say from Your error log: redis doesn't like special characters like < and >, so You have to encode them.
Use htmlspecialchars to encode and htmlspecialchars_decode to decode data when retrieving.
something is wrong with your redis client. You can not reproduce it, because the error does not happen in your code, but in TCP communication between client and redis server.
i would suggest to update the question and mention what redis client module are you using. Is it predis?
If you are on unix, try compile and install phpredis. it is php module and I never had any problems with it.
Reproduction with telnet
Do telnet host port and follow instructions:
Normal request GET a would look like this:
*2
$3
get
$1
a
$-1
Now consider this - ask for gem a:
*2
$3
gem
$1
a
-ERR unknown command 'gem'
Protocol is valid, but command "gem" is invalid.
Now consider this:
*1
$3
ml>
-ERR unknown command 'ml>'
Here is your error. Valid protocol, invalid command.
Alternatively consider this:
*2
$3
get
$1
<html>
$-1
-ERR unknown command 'ml>'
Here is your error again. Invalid strlen("<html>");
Why this is redis client error and not user error:
Many redis clients uses PHP magic methods.
This means if you call $redis->bla(), they extract "bla" part and it parameters and forward them to the redis server.
However you can not do $redis->ml>(). This will be syntax error. So this is error from redis client, not from your code.
It also looks like part of HTML. It looks like you are storing HTML data in redis. I only can guess that the client does not compute strlen() or count() and send wrong information "down the telnet line".
I've created this simple example based on wsdl mode sample of wso2 framework for php.
<?php
try {
$client = new WSClient(array("wsdl"=>"http://footballpool.dataaccess.eu/data/info.wso?wsdl",
));
$proxy = $client->getProxy();
$result = $proxy->TopGoalScorers(array('iTopN'=>1));
echo "TEST!!!<br />";
echo '<pre>';
print_r($result);
echo '</pre>';
} catch (Exception $e) {
echo "Message = ".$e->getMessage();
}
?>
If I execute this script in a web browser i got a http 324 error ERR_EMPTY_RESPONSE
And when i execute it in a shell it seems to work but at the end i get a segmentation fault error.
The same error will be reproduced using the sample file wsdl_11_client.php
If this line
$result = $proxy->TopGoalScorers(array('iTopN'=>1));
is commented no segmentation fault error will appear.
I'm using wsf wso2 framework for php version 2.1.0
libxml version 2.7.8
libxslt version 1.1.26
PHP Version 5.3.6-13ubuntu3.6
Ubuntu 11.10.
In my php.ini i've added
include_path = ".:/usr/share/php:/usr/lib/php5/20090626/wsf_c/scripts"
[wsf]
wsf.home="/usr/lib/php5/20090626/wsf_c"
;log_level2 shows warnings and errors
;wsf.log_level=2
;wsf.log_path="/var/log/wsf"
and i've added this extension in /etc/php5/conf.d/wsf.ini
; configuration for php WSF module
extension=wsf.so
Is my server misconfigurated? Or there are some errors in my php script?
Thanks in advance.
Francesco.
Same for me.
Taking into account the absence of activity on "WSO2 WSF for PHP" project, I suppose it would be better not to use it on production.
The best workaround probably would be to write Java proxy service which communicates with original service and returns something like JSON to PHP.