I am getting an error from Facebook in my application - facebook

I am creating an image from my Facebook application. I am getting the following error from Facebook.
CurlException: 56: SSL read: error:00000000:lib(0):func(0):reason(0),
errno 104
Is there anything wrong in my code?

Without looking at your code, or knowing if there is an actual issue w/ your SSL certificate (which you should NOT ignore), try something like this as a workaround:
<?php
$retry=False;
do {
try {
//your code goes here
$retry=False;
}
catch (Exception $e) {
echo $e->getMessage(), "\n";
$retry=True;
}
}
while ($retry);
?>

Related

Getting HTTP response from balanced

If I am using PHP code such as
$card = Balanced\Card::get("/v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC5N3HHUDrAyvhNwQOoUd3UX");
$card->unstore();
or
$customer->addCard($card)
how do I read the HTTP response from balanced to know if it has worked or what the error is?
The Balanced client libraries are written so that they will throw exceptions if there is a non 2xx HTTP response from the API.
The correct way to tell if the addCard operation failed for example would be to write some code that looks like
try {
$customer->addCard($card)
} catch (Balanced\Error $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}

Zend_Service_Yahoo showing sending request error. Status code: 404

I need your help.
I am facing a problem using Zend_Service_Yahoo.
I am trying to use Zend_Service_Yahoo. But it shows
"An error occurred sending request. Status code: 404"
$yahoo = new Zend_Service_Yahoo("YAHOO_APPLICATION_ID");
try{
$results = $yahoo->imageSearch('PHP');
foreach ($results as $result) {
echo $result->Title . '<br />';
}
}catch(Exception $e){
echo $e->getMessage();
}
Reference : http://framework.zend.com/manual/1.0/en/zend.service.yahoo.html
Thanks in advance
That's because imagesearch has been deprecated.
We’re shutting down this service in April 2011. For further details, please see the Deprecated Services blog post.

Google authentication

I got a problem on google authenticate, it worked for a month but since a few days I got this error :
Fatal error: Uncaught exception 'apiAuthException' with message
'Invalid token format' in /home/project/html/google/auth/apiOAuth2.php:127 Stack trace:
#0 /home/project/html/google/auth/apiOAuth2.php(89): apiOAuth2->setAccessToken('{? "access_tok...')
#1 /home/project/html/google/apiClient.php(132): apiOAuth2->authenticate(Array)
#2 /home/project/html/hk/connects/google.php(22): apiClient->authenticate()
#3 {main} thrown in /home/project/html/google/auth/apiOAuth2.php on line 127
In apiOAuth2.php I have the code :
$accessToken = json_decode($accessToken, true);
if (! isset($accessToken['access_token']) || ! isset($accessToken['expires_in']) || ! isset($accessToken['refresh_token'])) {
throw new apiAuthException("Invalid token format");
}
I noticed that google doesn't send me the $accessToken['refresh_token'].
It doesn't seem to come from google cause I did a correct connexion on http://stackoverflow.com
Maybe it's cause of my code :
session_start();
$client = new apiClient();
$plus = new apiPlusService($client);
if (!isset($_GET['code'])) {
header('Location: '.$client->createAuthUrl()); // Calls the same page
} else {
$client->authenticate(); // Fails at this level
}
EDIT:
I figured a way to do it, like I don't know what is refresh_token made for I added this line :
if (!isset($accessToken['refresh_token'])) $accessToken['refresh_token'] = 12345678910;
It works for the moment...
There is a new explicit parameter called "access_type" required by the google authentication api to obtain a valid refresh token.
With this parameter you declare that you need offline access to the account and the api provides you a refresh token.
Download the latest google PHP SDK that automatically handles the new required parameter

SoapClient error fallback in PHP

In PHP, if you try to instantiate a new SoapClient, and the WSDL is not accessible (server down or whatever), a PHP fatal error is thrown:
Fatal error: SOAP-ERROR: Parsing WSDL:
Couldn't load from
'http://example.com/servlet/app/SomeService?wsdl'
: failed to load external entity
"http://example.com/servlet/app/SomeService?wsdl"
Fatal errors in PHP, as far as I know, are not recoverable.
Is there any way to fallback from this? Can this fatal error somehow be avoided?
Edit: I should say that I am running on PHP 5.2, if it makes any difference.
This has already been discussed :
https://bugs.php.net/bug.php?id=47584
http://www.php.net/manual/en/class.soapclient.php#104046
Rasmus himself proposed the following solution:
<?php
try {
$x = #new SoapClient("non-existent.wsdl",array("exceptions" => 1));
} catch (SoapFault $E) {
echo $E->faultstring;
}
echo "ok\n";
See this topic How do I catch a PHP Fatal Error
Basically you cant recover from a fatal error but you can provide a better experience to the user when registering a shutdown function
register_shutdown_function('handleShutdown');
function handleShutdown(){
$error = error_get_last();
if($error !== NULL){
echo "Sorry for the inconvenience, an error just occurred.";
}
}

Zend Application - a 404 error instead of Zend_Acl_Exception - how?

At the present, when I type a wrong address I get the following:
exception 'Zend_Acl_Exception' with message 'Resource 'default_asda' not found' in /home/alkimi/www/ ...
I would like to, instead of this, display a costumized 404.
How can we configure the framework for doing so?
Thanks a lot,
MEM
You get that exception when you attempt to query your ACL for a non-existant resource. You should check your ACL for the resource before calling isAllowed, eg
if (!$acl->has($resource)) {
// do something that triggers or leads to a 404
}
You can check if action and controller exists (is dispatchable) before checking permissions:
$front = Zend_Controller_Front::getInstance();
if (!$front->getDispatcher()->isDispatchable($request)) {
throw new Zend_Exception('Page not found', 404);
return false;
}