What is meant by the below error?Why am i getting this.
Fatal error: Uncaught Exception: 601: Parser error: unexpected end of query. thrown in base_facebook.php on line 1039
I'm using a code to delete the invite once the user clicks on it from app tab,but this is not deleting the app request
Here is the code,
foreach ($request_ids as $request_id)
{
echo ("reqeust_id=".$request_id."<br>");
$full_request_id = build_full_request_id($request_id, $user_id);
echo ("full_request_id=".$full_request_id."<br>");
try {
$delete_success = $facebook->api("/$full_request_id",'DELETE');
if ($delete_success) {
echo "Successfully deleted " . $full_request_id;}
else {
echo "Delete failed".$full_request_id;}
}
catch (FacebookApiException $e) {
echo "error";}
}
Why is this bit in quotes?
$facebook->api("/$full_request_id",'DELETE');
Surely it should just be:
$facebook->api($full_request_id,'DELETE');
Other than that I see nothing wrong with your code. Although, it would be good to know what line 1039 in base_facebook.php is.
Related
So I've been trying to implement PayPal's GetVerifiedStatus API into my website but have been running into the following error:
Fatal error: Uncaught Error: Class 'PayPal\Types\AA\GetVerifiedStatusRequest' not found in C:\xampp\htdocs\paypaltest\getversys.php:14 Stack trace: #0 {main} thrown in C:\xampp\htdocs\paypaltest\getversys.php on line 14
What could the problem be? What I was able to figure out was that that particular directory is missing. But I have no idea as to how to get it because I've looked for it without any success.
I've been using exactly the same code as given by the PayPal SDK. Here it is:
<?php
use PayPal\Service\AdaptiveAccountsService;
use PayPal\Types\AA\AccountIdentifierType;
use PayPal\Types\AA\GetVerifiedStatusRequest;
require_once('bootstrap.php');
$getVerifiedStatus = new GetVerifiedStatusRequest();
$accountIdentifier=new AccountIdentifierType();
$accountIdentifier->emailAddress = $_REQUEST['emailAddress'];
$getVerifiedStatus->accountIdentifier=$accountIdentifier;
$getVerifiedStatus->firstName = $_REQUEST['firstName'];
$getVerifiedStatus->lastName = $_REQUEST['lastName'];
$getVerifiedStatus->matchCriteria = $_REQUEST['matchCriteria'];
$service = new AdaptiveAccountsService(Configuration::getAcctAndConfig());
try {
$response = $service->GetVerifiedStatus($getVerifiedStatus);
} catch(Exception $ex) {
require_once 'Common/Error.php';
exit;
}
$ack = strtoupper($response->responseEnvelope->ack);
if($ack != "SUCCESS"){
echo "<b>Error </b>";
echo "<pre>";
print_r($response);
echo "</pre>";
} else {
echo "<pre>";
print_r($response);
echo "</pre>";
echo "<table>";
echo "<tr><td>Ack :</td><td><div id='Ack'>$ack</div> </td></tr>";
echo "</table>";
}
require_once 'Common/Response.php';
So I'm answering my own question here because I contacted PayPal tech support and was told that the GetVerifiedStatus API is now deprecated and can't be used.
This is the reason for the error.
this is my code:
echo "START";
echo "<br />";
try {
$check = json_decode($soundcloud->get('me/followings/2521254'), true);
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}
echo "<br />";
echo "END";
When I execute the file it looks like this:
START
The requested URL responded with HTTP code 303.
The HTTP code 303 does mean that the user is following a specific person (if not it's 404), but that's not the point - this question is not SoundCloud API related.
The actual problem is: the echo (echo "END";) after the try block isn't executing.
What's the problem, how can I solve this?
I was able to install the Parse PHP SDK (version 1.1.2) to my project and got through the quick start guide in successfully creating a TestObject. However, when I tried to query the objects, it returns nothing. I'm stuck and don't know where to go from here.
use Parse\ParseQuery;
$query = new ParseQuery('TestObject');
$results = $query->find();
foreach($results as $result){
echo $result->getObjectId() ." - " $result->get("foo") . "\n";
}
You could try it this way:
$myObj= new ParseObject("TestObject");
$myObj->set("objIdd", 1234);
$myObj->set("objName", "My Name");
try {
$myObj->save();
echo 'New object created with objectId: ' . $myObj->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();
}
//objectId: "XYZABC", objIdd: 1234, objName: "My Name"
$query = new ParseQuery("TestObject");
try {
$myObj = $query->get("XYZABC");
// The object was retrieved successfully.
} catch (ParseException $ex) {
// The object was not retrieved successfully.
// error is a ParseException with an error code and message.
}
Take a look at this guide.
If i have a c1.php
<?php
class C1 {
function f1($value) {
if($value == 'ok') {
echo "OK!";
} else {
throw new Exception("WRONG!");
}
}
}
?>
and index.php
<?php
require_once('c1.php');
$c = new C1();
$c->f1('ok');
$c->f1('asd');
?>
Can anybody know, how to construct a well readable error message like "Error: you have wrong value in C:\xampp\htdocs\projekt\index.php: line 5" instead of tracktracing
OK!
Fatal error: Uncaught exception 'Exception' with message 'WRONG!' in
C:\xampp\htdocs\projekt\c1.php:7 Stack trace: #0
C:\xampp\htdocs\projekt\index.php(5): C1->f1('asd') #1 {main} thrown in
C:\xampp\htdocs\projekt\c1.php on line 7
that reading is a little difficult.
Catch the exception. This is the point of exceptions.. they are catchable and you can do something with the information (for instance.. output just the message).
You can do something like this:
try {
$c = new C1();
$c->f1('ok');
$c->f1('asd');
} catch(Exception $e) {
echo 'Error: you have wrong value in ', $e->getFile(), ' on line ', $e->getLine();
// ... code
}
i caught it
try {
..
} catch(Exception $e) {
//echo $e->getTraceAsString();
$t = $e->getTrace();
$t = $t[0];
echo 'Error: file - ',$t['file'],' - line: ',$t['line'],
' - function: ',$t['function'],'; ',$e->getMessage();
}
thank you for hints.
Simple, don't use an exception. They should be used when you're doing a try-catch or for an exceptional situation. This is not exceptional - meaning nothing can possibly turn an error with just a if-else statement.
So just echo out the error message of your choice.
i am try to use try() inside foreach in php for facebook application my app get user permissions than post on his 3 friends wall but the problem is that if one of user friends is non-postable than my app stop with error below is my code and error please take a look
foreach ($friends_list_array["data"] as $value) {
try
{
// compile the post for for user
$WallPost = array(
'access_token' => $atoken,
'message' => $value["name"] . ' .. message here ',
'link' => 'link_here');
// post to user wall
$response = $facebook->api('/' . $value["id"] . '/feed','POST',$WallPost);
echo ' posted on ' . $value["name"];
}
}
all works fine(except non-postable wall problem) without try() its shows error below is error
Parse error: syntax error, unexpected '}', expecting T_CATCH in
Can any one please solve this thank you
Look here
Each try must have at least one corresponding catch block
And thats the answer to your problem ( the error itself says about it, expecting T_CATCH)
If you do not need catch, just don't fill it with any logic, working example:
foreach ($friends_list_array["data"] as $value) {
try{
// do stuff...
}
catch(Exception $e){
// do nothing
}
}