Fatal error: Uncaught GraphMethodException in base_facebook.php - php

I am using the Facebook PHP SDK V3.2.3 and have built a web based app which simply gets users albums and pics and displays them on our site after the user authorises themselves.
I have tested the site functionality on different machines on different browsers/networks and everything works as expected from our side. We can authorise as the developers set on the account as well as the test user and authorise and see the pics/albums, problem free.
I submitted the app for review and it was denied - these are the notes returned.
When I click on the Facebook button, I receive the following error message,
" Fatal error: Uncaught GraphMethodException: Unsupported get request. thrown in
/home/websitename/public_html/sitedir/src/base_facebook.php
on line 1325."
Has anybody else had this issue? I am am completely at a loss as I can't debug this as I cannot recreate the problem.

It looks like you are trying to access something in your code that you do not have access to, or something that doesn't exist.
You should always wrap your Facebook API code in try...catch statements to catch any issues and fail gracefully.
try {
// some Facebook API call
} catch ( Exception $e ) {
// an error occurred
echo $e->getMessage();
}

Related

PHP - Zenfolio API - Error for method LoadGroupHierarchy

I am trying to bring photos from Zenfolio database using PHP. I keep receiving this error
Zenfolio API Error for method LoadGroupHierarchy: E_NOSUCHOBJECT (Error Code: 90009)
I am using admin username and password. Any ideas why?

catch exceptions from yodlee api

Currently I'm working with the yodlee API. As specified in the documentation the url response may throw InvalidCredentails or UserAccountLocked. I'm using PHP and I get the following response when the username or password is incorrect.
{
Error: [
{
errorDetail: "Invalid Cobrand Credentials"
}
]
}
So to check if the error occurs I want to write some code that checks if errorDetail has a value of Invalid Cobrand Credentials.
So far ok.
But the there may be so many types of errors, and each error name is different. My question is: Can I get the list of these errorDetail values
so that I can make it work without checking if the code is forcebly throwing the errors.
You can just check for the Error index and access it's value for throwing the errors. Something like this should work for you (not tested). From the repo page:
yodleeAPI.getAccounts(accessToken)
.then(function(response) {})
.catch(function(error) {});
Edit:
As far as I could tell there wasn't any exception list. So you're either going to have to go through all the exceptions manually or create a generic error message for users. I would just advice to catch the exception message and use that for the user view(if there isn't any security information in there). You can accomplish that by following the above code.
If you do feel the need to go through every exception yourself I managed to at least get the list of all methods that throw exceptions (search: exception). You'll have to go through it yourself, and parse the error message yourself. But you can find that here

Google and Facebook sign in conflict (PHP)

I'm trying to implement sign in with facebook and google in php.
They work perfectly separatly and there is no problems.
But when I try them together,it looks like facebook api try to connect with google authentication.
Exactly when i click on the facebook sign in, i have this error:
*Fatal error:
Uncaught exception 'Google_AuthException' with message 'Error fetching OAuth2 access token, message: 'invalid_grant'' in /Myfolder/MAMP/htdocs/My_app/google/vendor/google/api-client/src/auth/Google_OAuth2.php:114 Stack trace: #0 /Myfolder/MAMP/htdocs/My_app/google/vendor/google/api-client/src/Google_Client.php(131): Google_OAuth2->authenticate(Array, 'AQfjtxTYMHMZmEz...') #1 /Myfolder/MAMP/htdocs/My_app/classes/GoogleAuth.php(36): Google_Client->authenticate('AQfjtxTYMHMZmEz...') #2 /Myfolder/MAMP/htdocs/My_app/login.php(9): GoogleAuth->checkRedirectCode() #3 {main} thrown in /Myfolder/MAMP/htdocs/My_app/google/vendor/google/api-client/src/auth/Google_OAuth2.php on line 114
*
So i don't find a way to make work the facebook sign in without conflict with the checkRedirectCode() function for the goole api.
Has anyone had this problem or knows how to do?
I posted something yesterday but it wasn't a real answer so got deleted! Sorry for that guys.
Just as a background explanation, Adam here uses the facebook and google logins of the tutorial phpacademy. Since I use the same I know what he is talking about.
Allright!!!
So.......! Put both (google and fb) URIs to be the same target and try this:
in GoogleAuth class in its function checkRedirectCode() add this check before calling the function:
public function checkRedirectCode() {
if (!isset($_SESSION['facebook'])) {
if(isset($_GET['code']))
{
BLABLABLABLABLA
}
return true;
}
return false;
} else {
//skip this
echo "FB session on";
}
}
It worked for me, let me know if it does for you.
Basically you don't want to call that function if facebook is logged in! :)

Trouble Importing PHP Class

I am working with an API that has a "supported" library written by a third party.
I've done as the instructions say and feel I am very close to getting it working as it should however no matter what I try, (renaming, absolute paths, aggregated file paths, etc.) I'm getting the same error.
*I have an API key. This is not the issue
The error arises in this block:
define('API_KEY', ''); // //-- Insert your API key
define('PHP_SELF', htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'));
require_once("FFN.class.php");
$ffn = new FFN(API_KEY); //where actual error is thrown
if (!API_KEY) {
echo 'You did not set the API_KEY for your application. This is required.';
exit;
}
And states:
PHP Fatal error: Class 'FFN' not found in /st/3/g/public_html/path/nerdapi.php on line 16
The actual error is thrown on $ffn = new FFN(API_KEY);
If anyone can spot my probably very obvious error, I'd really appreciate it.
Here is the site where I got the 3rd party code for the API's
https://github.com/philip/FantasyNerdAPI
i download the file, and put up these file:
FFN.class.php
sdk.php
on htdocs/a and accessing localhost/a/sdk.php
result was : You did not set the API_KEY for your application. This is required.
well, i didnt put the key.

exception not being caught

I have the following PHP code on a web page:
$wsdl_url = "someURL?wsdl";
try {
$client = new SoapClient($wsdl_url, array('login' => 'mylogin','password' => 'mypassword'));
$client->myWebMethod(); // <-- problem call
} catch (Exception $e) {
echo "none";
}
It's a basic call to a web service. The problem is that when an error is thrown on the line $client->myWebMethod(), echo "none" is not printed. In fact, nothing in the catch block runs. Hence, I don't think the exception is being caught.
A fatal error is displayed on the web page.
Question: Any ideas on why this is happening? I expected all exceptions to be caught and handled with this code. But what I'm getting is that the fatal error is being displayed on the page. Maybe web services are handled differently?
EDIT: the error is that it's missing a bunch of required parameters. if I add the parameters the call works fine. I am purposely omitting the parameters to get the error, so i would know how to handle it.
The error is something like: Fatal error: SOAP-ERROR: Object hasn't 'myparameter1'
Thanks in advance.
I got the same exact problem this morning while running a custom module for Drupal which required an external SOAP Web Service. To be honest, I'm not quite sure how I solved the problem.
Turns out it was all about clearing my Web Server's cache that had to do with the respective WSDL. In your tmp/ folder you will find various files named wsdl-yourservice-etc. Delete them and it should be OK. If not, the problem lies in the code and more specifically in the sequence and syntax of the arguments passed to the WSDL.
I hope I helped.
Unfortunately, this is not a catchable error.
However, you can check if the soap extension is loaded before trying to instantiate it by calling get_loaded_extensions with something along the lines of:
if (in_array('soap', get_loaded_extensions())) {
// it's loaded!
}

Categories