This is the first time I use parse.com php SDK and I try to execute the following code
<?php require '../autoload.php';
use Parse\ParseObject;
use Parse\ParseClient;
ParseClient::initialize( "Zsr...", "BzM..", "D..." );
$gameScore = new ParseObject("GameScore");
$gameScore->set("score", 1337);
$gameScore->set("playerName", "Sean Plott");
$gameScore->set("cheatMode", false);
try {
$gameScore->save();
echo 'New object created with objectId: ' . $gameScore->getObjectId();
} catch (ParseException $ex) {
// Execute any logic that should take place if the save fails.
// error is a ParseException object with an error code and message.
echo 'Failed to create new object, with error message: ' + $ex->getMessage();
}
?>
But I get that error
Fatal error: Uncaught exception 'Parse\ParseException' with message 'SSL certificate problem: unable to get local issuer certificate' in /opt/lampp/htdocs/parse/src/Parse/ParseClient.php:250 Stack trace: #0 /opt/lampp/htdocs/parse/src/Parse/ParseObject.php(925): Parse\ParseClient::_request('POST', '/1/classes/Game...', NULL, '{"score":1337,"...', false) #1 /opt/lampp/htdocs/parse/src/Parse/ParseObject.php(836): Parse\ParseObject::deepSave(Object(Parse\ParseObject), false) #2 /opt/lampp/htdocs/parse/src/hola.php(11): Parse\ParseObject->save() #3 {main} thrown in /opt/lampp/htdocs/parse/src/Parse/ParseClient.php on line 250
The code it's the tutorial code, iI haven't changed anything anyone knows what's the problem?
I am also getting same issue. Now I resolve using some other forums answer.
Open your ParseClient.php and find:
curl_init();
And after that add line add:
curl_setopt($rest, CURLOPT_SSL_VERIFYPEER, false);
It will work.
Related
When i try to run php code using Parse.com PHP SDK it
the error is "Account already exists for this username"
but it throw all this error message:
Fatal error: Uncaught exception 'Parse\ParseException' with message 'Account already exists for this username' in /Users/yousef/Desktop/project/vendor/parse/php-sdk/src/Parse/ParseClient.php:357 Stack trace: #0 /Users/yousef/Desktop/project/vendor/parse/php-sdk/src/Parse/ParseObject.php(1038): Parse\ParseClient::_request('POST', 'classes/_User', NULL, '{"username":"my...', false) #1 /Users/yousef/Desktop/project/vendor/parse/php-sdk/src/Parse/ParseObject.php(947): Parse\ParseObject::deepSave(Object(Parse\ParseUser), false) #2 /Users/yousef/Desktop/project/vendor/parse/php-sdk/src/Parse/ParseUser.php(108): Parse\ParseObject->save() #3 /Users/yousef/Desktop/project/test.php(20): Parse\ParseUser->signUp() #4 {main} thrown in /Users/yousef/Desktop/project/vendor/parse/php-sdk/src/Parse/ParseClient.php on line 357
The Code i Use
<?php
require 'vendor/autoload.php';
use Parse\ParseClient;
ParseClient::initialize('YousefId', '', 'YousefMaster');
ParseClient::setServerURL('server-ip:1337/parse');
use Parse\ParseUser;
$user = new ParseUser();
$user->set("username", "my name");
$user->set("password", "my pass");
$user->set("email", "email#example.com");
$user->set("phone", "415-392-0202");
try {
$user->signUp();
} catch (ParseException $error) {
echo $error->getCode();
echo $error->getMessage();
}
?>
so how do i just show the error code and message instead of showing all this error.
You need to refer to the ParseException within the Parse namespace.
Try
catch (Parse\ParseException $error) {
// ...
}
I am trying to ultimately run and display reports from a remote Jasper Server in a PHP application. What I am trying to do this with is the jrs-rest-php-client project on github.
The error:
Fatal error: Uncaught exception 'Jaspersoft\Exception\RESTRequestException' with message 'An unexpected HTTP status code was returned by the server' in C:\xampp\htdocs\jrs\vendor\src\Jaspersoft\Tool\RESTRequest.php:409
Stack trace:
#0 C:\xampp\htdocs\jrs\vendor\src\Jaspersoft\Tool\RESTRequest.php(479): Jaspersoft\Tool\RESTRequest->handleError(0, Array, false)
#1 C:\xampp\htdocs\jrs\vendor\src\Jaspersoft\Service\ReportService.php(40): Jaspersoft\Tool\RESTRequest->prepAndSend('https://jasper....', Array, 'GET', NULL, true)
#2 C:\xampp\htdocs\jrs\report.php(30): Jaspersoft\Service\ReportService->runReport('/Reports/Distri...', 'html')
#3 {main} thrown in C:\xampp\htdocs\jrs\vendor\src\Jaspersoft\Tool\RESTRequest.php on line 409
My PHP:
require_once __DIR__ . "/vendor/autoload.php";
use Jaspersoft\Client\Client;
$d = new Client(
"http://jasper.server.com/jasperserver-pro",
"username",
"password",
"organization"
);
$info = $d->serverInfo();
Any ideas?
Looking into the code of RESTRequest.php there are two cases in which this exception is thrown:
A JSON result set with an unknown error code is returned (unknown meaning different from 200 OK)
No JSON result set is returned at all
So I suspect the connection isn't working properly. To find out more, you should catch the exception in your code and evaluate it:
It could look something like this (I'm more familiar with Java):
try {
$d = new Client(
"http://jasper.server.com/jasperserver-pro",
"username",
"password",
"organization"
);
$info = $d->serverInfo();
} catch (RESTRequestException $e) {
echo 'RESTRequestException:';
echo 'Exception message: ', $e->getMessage(), "\n";
echo 'Set parameters: ', $e->parameters, "\n";
echo 'Expected status code:', $e->expectedStatusCodes, "\n";
echo 'Error code: ', $e->errorCode, "\n";
}
If there is still an error, you can check the following:
Can you reach the jasper server from the server where this code is deployed? Sometimes e.g. firewall settings can interfere.
Is the organization called exactly like defined in the properties of the organization in the server? (Open repository / right click on organization / properties / resource-id)
I use this code
#!/usr/bin/php
<?php
require_once('whatsapp_whatsapi_config.php');
$destinationPhone = 'xxxx';
$w = new WhatsProt($userPhone,0, $userName, $debug);
$w->Connect();
$w->LoginWithPassword($password);
$message = 'WhatsApp';
$w->Message($destinationPhone, $message);
echo "Mensaje enviado exitosamente";
?>
and this error displayed
PHP Fatal error: Uncaught exception 'LoginFailureException' in /var/www/html/whats/src/whatsprot.class.php:2274
Stack trace:
/var/www/html/whats/src/whatsprot.class.php(552): WhatsProt->doLogin()
/var/www/html/whats/whatsapp_whatsapi_send.php(13): WhatsProt->loginWithPassword('Mu7q0hq/vRSLFCU...')
{main}
thrown in /var/www/html/whats/src/whatsprot.class.php on line 2274
I tried use the WART app but the password generated is incorrect
Add a try-catch clause on the line that has $w->LoginWithPassword($password); and use the getMessage() method on the exception to see what the error message is, and what might be wrong with your login
I'm currently having a really frustrating time with some really simple SOAP / PHP at the moment. I've spent about a week trying EVERYTHING I can think of, on multiple different servers with different versions of PHP and they all still throw the same error. Here's the code:
function test() {
$client = new SoapClient('http://xxx', array("login" => "sandbox", "password" => "password"));
print_r($client->__getFunctions());
$ap_param = array();
// it dies here. CheckServiceAvailable is a valid function returned in __getFunctions()
$result = $client->__soapcall('CheckServiceAvailable', $ap_param);
if (is_soap_fault($result)) {
trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
}
}
It faults before the error catching can capture anything. Apache logs show the same fault as below:
Fatal error: Uncaught SoapFault exception: [s:Processing error] in C:\soap.php:13 Stack trace: #0 C:\soap.php(13): SoapClient->__soapCall('CheckServiceAva...', Array) #1 C:\soap.php(23): test() #2 {main} thrown in C:\soap.php on line 13
Without being able to catch the fault I'm totally stuck as to what to do. I don't really want to try nusoap.
Any ideas?
use:
try
{
$result = $client->__soapcall('CheckServiceAvailable', $ap_param);
}
catch (SoapFault $e)
{
echo "Cannot call method CheckServiceAvailable: {$e->getMessage()}";
}
I am trying to implement the whatsAPI but I always get this error
"There was a problem trying to request the code".
Here is the full error that is showing in my console:
####start of error notice#####
[12-Mar-2013 22:44:59] PHP Notice: Undefined property: stdClass::$reason in /Applications/MAMP/htdocs/whatsapp/test/whatsprot.class.php on line 1268
[12-Mar-2013 22:44:59] PHP Fatal error: Uncaught exception 'Exception' with message 'There was a problem trying to request the code.' in /Applications/MAMP/htdocs/whatsapp/test/whatsprot.class.php:1269
Stack trace:
#0 /Applications/MAMP/htdocs/whatsapp/test/test.php(36): WhatsProt->checkCredentials()
#1 {main}
thrown in /Applications/MAMP/htdocs/whatsapp/test/whatsprot.class.php on line 1269
####end of error notice#####
these are my credentials for initializing the class
$userPhone = '8801770648732';
$userIdentity = '352264050503669';
$userName = 'shishir';
$destinationPhone = '8801713206053';
$debug = TRUE;
$whatsapp = new WhatsProt($userPhone, $userIdentity, $userName, $debug);
and for the requesting a requestCode
$service_type = "sms";
$country_code = "BD";
$language_code = "en";
$request_code = $whatsapp->requestCode($service_type, $country_code, $language_code);
Every time it stuck at the $whatsapp->requestCode with that error. I'm not sure what i am doing wrong . Can anyone help me on this?
It's look like you don't have curl extension.
This Exception is thrown by checkCredentials method.
Check if your phpinfo shows curl.