Verify the receipt using curl, but the response is null - ios5

I verify the receipt using curl, but the response is null. I write the code according this blog. How to fix it?
<?php
$receipt="<7b0a0922 7369676e 61747572 6522203d 20224167 42423765 756e316d 79366745 64755561 4d7a4841 53664363 33315874 6c674439 52316b6d 4c454d35 54436654 67513578 6e576a57 2b395636 2f634141 2f454b37 66624956 524f6454 54613736 6a332f72 544b364d 632f4f74 464b6b43 71615543 5046385a 38334349 47554274 6e564c37 4b4b3679 47494d6b 59705158 46727948 42473346 762b584f 36614747 76396178 794a4359 716b312f 56737047 36586b44 68786a59 7359445a 717a4141 4144567a 43434131 4d776767 49376f41 4d434151 49434347 55556b55 335a5741 53314d41 30474353 71475349 62334451 45424251 55414d48 3878437a 414a4267 4e564241 5954416c 56544d52 4d774551 59445651 514b4441 70426348 42735a53 424a626d 4d754d53 59774a41 59445651 514c4442 31426348 42735a53 42445a58 4a306157 5a705932 46306157 39754945 46316447 6876636d 6c306554 457a4d44 45474131 55454177 77715158 42776247 55676156 5231626d 567a4946 4e306233 4a6c4945 4e6c636e 52705a6d 6c6a5958 52706232 34675158 56306147 39796158 52354d42 34584454 41354d44 59784e54 49794d44 55314e6c 6f584454 45304d44 59784e44 49794d44 55314e6c 6f775a44 456a4d43 45474131 55454177 77615548 56795932 68686332 56535a57 4e6c6158 42305132 56796447 6c6d6157 4e686447 5578477a 415a4267 4e564241 734d456b 46776347 786c4947 6c556457 356c6379 42546447 39795a54 45544d42 45474131 55454367 774b5158 42776247 55675357 356a4c6a 454c4d41 6b474131 55454268 4d435656 4d77675a 38774451 594a4b6f 5a496876 634e4151 45424251 41446759 30414d49 474a416f 4742414d 72526a46 32637434 49725364 69544368 61493067 38707776 2f636d48 7338702f 5277562f 72742f39 31584b56 684e6c34 58494269 6d4b6a51 514e6667 48734473 36796a75 2b2b4472 4b4a4537 754b7370 684d6464 4b596646 45357247 58734164 42456a42 77524978 65785465 76783348 4c454647 4174316d 6f4b7835 30396468 78746949 6444674a 76325961 56733439 4230754a 764e6479 36534d71 4e4e4c48 73444c7a 4453396f 5a484167 4d424141 476a636a 42774d41 77474131 55644577 45422f77 51434d41 41774877 59445652 306a4242 6777466f 41554e68 336f3470 32433067 45597454 4a724474 64444335 4659517a 6f774467 59445652 30504151 482f4241 51444167 65414d42 30474131 55644467 51574242 53706734 50794755 6a465068 4a584342 544d7a61 4e2b6d56 386b3954 41514267 6f71686b 69473932 4e6b4267 55424241 49464144 414e4267 6b71686b 69473977 30424151 55464141 4f434151 45414561 5362506a 746d4e34 432f4942 33514570 4b333252 78616343 44586456 58416556 52655335 46615a78 632b7438 38705150 39334269 41787664 572f3365 54534d47 59354662 6541594c 33657471 5035676d 38777246 6f6a5830 696b7956 52537451 2b2f4151 304b456a 74714230 376b4c73 39515565 38637a52 38554766 644d3145 756d562f 55677644 64344e77 4e59784c 514d6734 57545166 676b5151 56793847 585a7756 48676245 2f554336 59373035 33704758 426b3531 4e504d33 776f7868 64336753 524c7658 6a2b6c6f 48735374 63544571 65397042 44706d47 352b736b 3474772b 474b3347 4d65454e 352f2b65 31515439 6e702f4b 6c316e6a 2b614277 37433078 73793062 466e6141 64316353 53367864 6f72792f 4355764d 3667744b 736d6e4f 4f647154 65736270 30627338 736e3657 71733043 39646763 78524875 4f4d5a32 746d386e 704c556d 37617267 4f537a51 3d3d223b 0a092270 75726368 6173652d 696e666f 22203d20 2265776f 4a496d39 79615764 70626d46 734c5842 31636d4e 6f59584e 6c4c5752 68644755 7463484e 30496941 39494349 794d4445 794c5445 794c5445 77494441 304f6a45 304f6a4d 32494546 745a584a 70593245 76544739 7a583046 755a3256 735a584d 694f776f 4a496e42 31636d4e 6f59584e 6c4c5752 68644755 7462584d 69494430 67496a45 7a4e5459 7a4f5463 324d7a4d 324d7a49 694f776f 4a496e56 75615846 315a5331 705a4756 7564476c 6d615756 79496941 39494349 774d4441 77596a41 794f5745 344d5467 694f776f 4a496d39 79615764 70626d46 734c5852 79595735 7a59574e 30615739 754c576c 6b496941 39494349 784d4441 774d4441 774d4459 774d5463 314d7a67 7a496a73 4b43534a 6c654842 70636d56 7a4c5752 68644755 69494430 67496a45 7a4e5459 7a4f5463 344d544d 324d7a49 694f776f 4a496e52 79595735 7a59574e 30615739 754c576c 6b496941 39494349 784d4441 774d4441 774d4459 774f5445 774e5463 7a496a73 4b43534a 76636d6c 6e615735 68624331 7764584a 6a614746 7a5a5331 6b595852 6c4c5731 7a496941 39494349 784d7a55 314d5451 784e6a63 324d4441 77496a73 4b43534a 335a5749 7462334a 6b5a5849 7462476c 755a5331 70644756 744c576c 6b496941 39494349 784d4441 774d4441 774d4449 324e446b 334f4451 7a496a73 4b43534a 69646e4a 7a496941 39494349 784c6a41 694f776f 4a496d56 3463476c 795a584d 745a4746 305a5331 6d62334a 74595852 305a5751 7463484e 30496941 39494349 794d4445 794c5445 794c5449 30494445 334f6a45 774f6a45 7a494546 745a584a 70593245 76544739 7a583046 755a3256 735a584d 694f776f 4a496d6c 305a5730 74615751 69494430 67496a55 344e6a45 324d7a4d 774e4349 3743676b 695a5868 7761584a 6c637931 6b595852 6c4c575a 76636d31 68644852 6c5a4349 67505341 694d6a41 784d6930 784d6930 794e5341 774d546f 784d446f 784d7942 4664474d 76523031 55496a73 4b43534a 77636d39 6b64574e 304c576c 6b496941 3949434a 6a623230 75615746 75597935 68634842 7764584a 6a614746 7a5a5335 7a5a585a 6c626d52 6865584d 694f776f 4a496e42 31636d4e 6f59584e 6c4c5752 68644755 69494430 67496a49 774d5449 744d5449 744d6a55 674d4445 364d4463 364d544d 67525852 6a4c3064 4e564349 3743676b 6962334a 705a326c 75595777 74634856 79593268 68633255 745a4746 305a5349 67505341 694d6a41 784d6930 784d6930 784d4341 784d6a6f 784e446f 7a4e6942 4664474d 76523031 55496a73 4b43534a 69615751 69494430 67496d4e 76625335 70595735 6a4c6d46 7763484e 31596e4e 6a636d6c 7764476c 76626e4d 694f776f 4a496e42 31636d4e 6f59584e 6c4c5752 68644755 7463484e 30496941 39494349 794d4445 794c5445 794c5449 30494445 334f6a41 334f6a45 7a494546 745a584a 70593245 76544739 7a583046 755a3256 735a584d 694f776f 4a496e46 31595735 30615852 35496941 39494349 78496a73 4b66513d 3d223b0a 0922656e 7669726f 6e6d656e 7422203d 20225361 6e64626f 78223b0a 0922706f 6422203d 20223130 30223b0a 09227369 676e696e 672d7374 61747573 22203d20 2230223b 0a7d>";
$data= array("receipt-data"=>$receipt,"password"=>"12345678");
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"https://sandbox.itunes.apple.com/verifyReceipt");
curl_setopt($ch,CURLOPT_POST,1);
//curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
$response = curl_exec($ch);
$errno = curl_errno($ch);
$errmsg = curl_error($ch);
echo "response: ".$response;
echo "<br/>";
//$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$result = json_decode($response);
echo "errno: ".$errno;
echo "<br/>";
echo "errmsg: ".$errmsg;
echo "<br/>";
//echo "code:".$httpCode;
echo "result: ".$result;
curl_close($ch);
?>
The result is:
response:
errno: 0
errmsg:
result:

I have test your code, it work well, so i think you should check your server environment!

Related

How create WMS layer in GeoServer by REST API?

In PostgreSQL I have a scheme called geo. Inside that scheme, I have a table with a column which has a geometry data type.
I am new in GeoServer and want to know how to create WMS layer by REST API with data of that remote PostgreSQL database? According to the documentation I need to create workspace and datastore first, right? I'm a little confused. What sequence of actions should be? I will be grateful for any example!
Result of curl request:
The REST API works in exactly the same manner as the GUI, so the process is that you can optionally create a new workspace or use an existing one, you then create a store inside a workspace and then create layers from the store. Any layer will automatically become available as a WMS layer.
Create a new PostGIS store, generate a file with the connection details:
<dataStore>
<name>nyc</name>
<connectionParameters>
<host>localhost</host>
<port>5432</port>
<database>nyc</database>
<user>bob</user>
<passwd>postgres</passwd>
<dbtype>postgis</dbtype>
</connectionParameters>
</dataStore>
and POST it to the REST endpoint
curl -v -u admin:geoserver -XPOST -T <file.xml> -H "Content-type: text/xml"
http://localhost:8080/geoserver/rest/workspaces/<WORKSPACENAME>/datastores
Then publish the table as a layer
curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d "<featureType><name>buildings</name></featureType>" http://localhost:8080/geoserver/rest/workspaces/acme/datastores/nyc/featuretypes
optional.
Publishing a table from an existing PostGIS store.
on php curl.
function curl_post($url,$params) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD,"user:password");//--> on geoserver.
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Receive server response ...
$response = curl_exec($ch);
curl_close ($ch);
return $response;
}
//- table_name : xxx
//- work_space_name : your_workspace
//- store_name : dbtest
$layer_name = "xxx";
$params ="
<featureType>
<name>".$layer_name."</name>
<nativeName>".$layer_name."</nativeName>
<title>".$layer_name."</title>
<keywords>
<string>".$layer_name."</string>
<string>features</string>
</keywords>
<srs>EPSG:3857</srs>
<nativeBoundingBox>
<minx>1.0836244E7</minx>
<maxx>1.1759454E7</maxx>
<miny>625842.375</miny>
<maxy>2328151.75</maxy>
</nativeBoundingBox>
<latLonBoundingBox>
<minx>97.34363607648459</minx>
<maxx>105.63697261100442</maxx>
<miny>5.613037739416236</miny>
<maxy>20.464604971116074</maxy>
</latLonBoundingBox>
<projectionPolicy>FORCE_DECLARED</projectionPolicy>
<enabled>true</enabled>
<metadata>
<entry key=\"cachingEnabled\">false</entry>
</metadata>
<maxFeatures>0</maxFeatures>
<numDecimals>0</numDecimals>
</featureType>
";
$str_url = "http://xxx.co.uk/geoserver/rest/workspaces/**your_workspace**/datastores/**your_data_store**/featuretypes";
$rs = curl_post($str_url, $params);

Error Paypal REST API (sandbox) 404:"The requested URL /cgi-bin/ppapi was not found on this server."

I'm using PHP curl and it is communicating with the server. I'm trying to get a token. I get the following unhelpful response from the paypal sandbox:
Not Found
The requested URL /cgi-bin/ppapi was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at api.sandbox.paypal.com Port 443
I'm running the code (below) from localhost on my laptop.
/gettoken.php
<?php
//header('Content-Type:application/javascript');
$url = "https://api.sandbox.paypal.com/token";
$client_id = "xxx";
$secret = "xxx";
// Initiate curl
$ch = curl_init();
// set basic auth
curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_BASIC);
// set user/password
curl_setopt($ch,CURLOPT_USERPWD,$client_id.":".$secret);
// set header accept
$headers = array('Accept:application/json','Accept-Language:en_US');
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
// set mode to POST
curl_setopt($ch,CURLOPT_POST,1);
// add post fields (1)
$fields_string = "grant_type=client_credentials";
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
// Disable SSL verification
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
if($result === false)
{
echo 'Curl error: ' . curl_error($ch);
}
// close curl
curl_close($ch);
// decode result
//var json = json_decode($result, true);
echo('<pre>'.$result.'</pre>');
?>
My apologies, the url to the REST service was wrong.. should have been:
https://api.sandbox.paypal.com/v1/oauth2/token
At least we know that if you get this error that it is likely the REST endpoint url is probably wrong.

fql multiquery giving bad request error, failed to open stream

$fql_multiquery_url = 'https://graph.facebook.com/'
. 'fql?q={"query1":"SELECT+uid,sex,name,pic_square+FROM+user+WHERE+uid+IN+(SELECT+uid2+FROM+friend+WHERE+uid1=me())+AND+sex=\"'.$sex.'\"","query2":"SELECT+url+FROM+profile_pic+WHERE+id+IN+(SELECT+uid+FROM+#query1)"}'
. '&access_token=' . $access_token;
This gives error
failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request\r\n in /var/www/facebook-php-sdk-master/examples/fqlsample.php on line 82
but the below query works fine.
$fql_multiquery_url = 'https://graph.facebook.com/'
. 'fql?q={"query1":"SELECT+uid,sex,name,pic_square+FROM+user+WHERE+uid+IN+(SELECT+uid2+FROM+friend+WHERE+uid1=me())+AND+sex=\"'.$sex.'\"","query2":"SELECT+url+FROM+profile_pic+WHERE+id+IN+(SELECT+uid2+FROM+friend+WHERE+uid1=me())"}'
. '&access_token=' . $access_token;
the problem is in thhis part
(SELECT+uid+FROM+#query1)
why the multi query fails to work.
any idea?

How to use crocdoc in php

I am using crocdoc in php
https://github.com/crocodoc/crocodoc-php
i downloaded the files in my local i had my API TOKEN so i pasted it there but it doesnt seems to work and throws error shown below for all 15 examples
can any one help me here
This is the error here which i am getting on using above github code with my Token
Example #1 - Upload Form W4 from the IRS by URL.
Uploading... failed :(
Error Code: curl_exception
Error Message: Crocodoc: [curl_exception] Crocodoc::_request
{"curl_errno":60,"curl_error":"SSL certificate problem, verify that the CA cert is OK. Details:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed"}
Example #15 - Delete the second file we uploaded.
Deleting... failed :(
Error Code: curl_exception
Error Message: Crocodoc: [curl_exception] Crocodoc::_request
{"curl_errno":60,"curl_error":"SSL certificate problem, verify that the CA cert is OK. Details:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed"}
To check i am using the crocodoc API properly i wrote my own code
this is the error i am getting in my own code
::::OUTPUT::::
{"uuid": "300dc39d-e82b-4d92-a701-b1f376600b96"}
checking status of : {"uuid": "300dc39d-e82b-4d92-a701-b1f376600b96"}
Curl error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Curl error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Curl error no: 60
out put for docurlGet is :
bool(false) status is :
Viewing the Document : {"uuid": "300dc39d-e82b-4d92-a701-b1f376600b96"}
this is my code (i am sorry if i am not suppose to paste the whole code but could not understand the whole issue so i am just giving whole code )
<?php
$myToken='gSqV0PpEZhvJfLxQTcuMmoty';
$frameUrl='https://crocodoc.com/api/v2/document/upload';
$api_url = 'https://crocodoc.com/api/v2/';
//curl "https://crocodoc.com/api/v2/document/upload" --data "token=${API_TOKEN}&url=http://web.crocodoc.com/files/test-simple.pdf"
$param='token='.$myToken.'&url=http://web.crocodoc.com/files/test-simple.pdf';
//curl command
$ch = curl_init();
#curl_setopt($ch, CURLOPT_HEADER, 0);
#curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'X-HTTP-Method-Override: POST'));
#curl_setopt($ch, CURLOPT_POST, 1);
#curl_setopt($ch, CURLOPT_URL, $frameUrl);
#curl_setopt($ch, CURLOPT_POSTFIELDS,$param);
#curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
#curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
$uuids = curl_exec($ch);
echo $uuids;
echo "<br>";
echo " checking status of : ", $uuids."<br>";
$status =getStatus($uuids,$api_url,$myToken);
//curl 'https://crocodoc.com/api/v2/document/status?token=F6JOdArWGKmDRlfPQcZna71x&uuids=d5ea0542-baaf-46a1-835c-685a86e70e14'
echo " status is : ", $status."<br>";
echo " Viewing the Document : ", $uuids."<br>";
function getStatus($uuids,$api_url,$myToken){
$isSingleUuid = is_string($uuids);
$obj = json_decode($uuids);
$my_uuid= $obj->uuid;
$url = $api_url.'document/status';
$token = $myToken;
$dataStr = '?token='.$token.'&uuids='.$my_uuid;
$output = my_doCurlGet($url, $dataStr);
var_dump($output);
return $output;
}
function my_doCurlGet($url, $dataStr) {
//var_dump($url.$dataStr);
// var_dump($dataStr);exit;
//
$ch1 = curl_init();
#curl_setopt($ch1, CURLOPT_HEADER, 0);
#curl_setopt($ch1, CURLOPT_HTTPHEADER, array('Accept: application/json', 'X-HTTP-Method-Override: POST'));
#curl_setopt($ch1, CURLOPT_POST, 1);
#curl_setopt($ch1, CURLOPT_URL, $url.$dataStr);
#curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch1);
if(curl_exec($ch1) === false)
{
echo "<br>".'Curl error: ' . curl_error($ch1);
}
else
{
echo "<br>".'Operation completed without any errors'."<br>";
}
//var err_no=curl_errno()
if(curl_errno($ch1))
{
echo "<br>".'Curl error: ' . curl_error($ch1);
echo "<br>".'Curl error no: ' . curl_errno($ch1);
}
echo "<br>". "out put for docurlGet is : $output"."<br>";
return $output;
}
if (curl_errno($ch)) {
print 'An curl error has occurred.';
exit;
}
//var_dump($uuids);
curl_close($ch);
return $uuids;
?>
Thanks for all your help
Curl probably isn't properly configured with a CA bundle, or the configured CA bundle does not include Crocodoc's CA cert.
Check out this answer for more info.
Found the answer
First of all i did enable curl and SSL for beginning but it was not working
i even changed my Localhost name to myHost but it still did not work
so I made few changes in crocodoc.php file which i downloaded from crocodoc api library
CROCODOC PHP LIBRARY
I added this lines and IT WORKED :):):) Thank you all, hope this helps someone else as well.
if(($_SERVER['SERVER_NAME'] == 'myHost') && ($_SERVER['SERVER_ADDR'] == '127.0.0.1') && ($_SERVER['HTTP_HOST'] == 'myHost')) {
$options[CURLOPT_SSL_VERIFYPEER]=false;
}

Error in in my first zend app

hello all its my first application using Zend Framework i have followed tutorial it was very nice and simple after finishing i got the following error .anyone please tell me why i am getting this ??
Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in C:\xampp\htdocs\zend_login\library\Zend\Controller\Dispatcher\Standard.php:248
Stack trace:
#0 C:\xampp\htdocs\zend_login\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 C:\xampp\htdocs\zend_login\library\Zend\Controller\Front.php(212): Zend_Controller_Front->dispatch()
#2 C:\xampp\htdocs\zend_login\web_root\index.php(9): Zend_Controller_Front::run('/application/co...')
#3 {main}
Next exception 'Zend_Controller_Exception' with message 'Invalid controller specified (error)
#0 C:\xampp\htdocs\zend_login\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 C:\xampp\htdocs\zend_login\library\Zend\Controller\Front.php(212): Zend_Controller_Front->dispatch()
#2 C:\xampp\htdocs\ in C:\xampp\htdocs\zend_login\library\Zend\Controller\Plugin\Broker.php on line 336
this is my index.php in web_root folder
<?php
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', true);
date_default_timezone_set('Europe/London');
$rootDir = dirname(dirname(__FILE__));
set_include_path($rootDir . '/library' . PATH_SEPARATOR . get_include_path());
$rootDir . '/library' . PATH_SEPARATOR . get_include_path();
require_once 'Zend/Controller/Front.php';
Zend_Controller_Front::run('/application/controllers');
?>
You have configured the error handler of Zend but there is no error handler controller. Your real problem should lie behind this.
Create a file ErrorController.php inside of your controllers directory with the following contents:
class ErrorController extends Zend_Controller_Action
{
/**
* Handles system errors and 404s
*/
public function errorAction()
{
$errors = $this->_getParam('error_handler');
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404);
$priority = Zend_Log::NOTICE;
$this->view->message = 'Page not found';
break;
default:
// application error
$this->getResponse()->setHttpResponseCode(500);
$priority = Zend_Log::CRIT;
$this->view->message = 'Application error';
break;
}
// Log exception, if logger available
if ($log = $this->getLog()) {
$log->log($this->view->message, $priority, $errors->exception);
$log->log('Request Parameters', $priority, $errors->request->getParams());
}
// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {
$this->view->exception = $errors->exception;
}
$this->view->request = $errors->request;
}
/**
* Get the log
*
* #return Zend_Log|false
*/
public function getLog()
{
$bootstrap = $this->getInvokeArg('bootstrap');
if (!$bootstrap->hasResource('Log')) {
return false;
}
$log = $bootstrap->getResource('Log');
return $log;
}
}
And the corresponding view views/error/error.phtml:
<h2><?php echo $this->message ?></h2>
<?php if (isset($this->exception)): ?>
<h3>Exception information:</h3>
<p>
<b>Message:</b> <?php echo $this->exception->getMessage() ?>
</p>
<h3>Stack trace:</h3>
<pre><?php echo $this->exception->getTraceAsString() ?></pre>
<h3>Request Parameters:</h3>
<pre><?php echo $this->escape(var_export($this->request->getParams(), true)) ?></pre>
This are more or less the defaults the Zend Framework scripts create on creation of a new project (They are modified a little since I do not have a clean version at the moment and no time to create a new project - But it should work.)
You may read more on the error handler here: http://framework.zend.com/manual/en/zend.controller.plugins.html#zend.controller.plugins.standard.errorhandler