I'm using the google-api-php-client (https://github.com/google/google-api-php-client)
When I try to connect to the Freebase service I get the following error:
Fatal error: Call to undefined method Google_Service_Freebase::call()
Here's a snippet of my code:
$freebase->search(array('automotive');
The search function in the Freebase service looks like this:
public function search($optParams = array())
{
$params = array();
$params = array_merge($params, $optParams);
return $this->call('search', array($params));
}
It calls to an internal function call, but it doesn't exists in the class..
Anyone suggestions?
I took a look at the lib code (which is in beta and changed a lot since the last version), I think that return line should be:
return $this->base_methods->call('search', array($params));
I can't try this now, but if you do and it work, you could submit a bug report on their Github (I saw your post there :).
Related
I am working to get response from dutchie GrapghQL api using PHP, These are working fine with POSTMAN , but when I am trying to get them work with below Library , its not working at all, and there is very less documentation available for dutchie(php graghql)
https://github.com/webonyx/graphql-php/
Before I have worked on rest apis with php MySQL, its totally new thing to me so not getting how get it work
Postman working image
<?php
include("library/graphQL/vendor/autoload.php");
use GraphQL\Client;
use GraphQL\Exception\QueryError;
$client = new Client(
'https://plus.dutchie.com/plus/2021-07/graphql',
["Authorization" => "public- eyJhbGciOiJIUzI1NiJ9."]
);
// Create the GraphQL mutation
$gql = (new Mutation('Ping'))
->setSelectionSet(
[
'id',
'time',
]
);
// Run query to get results
try {
$results = $client->runQuery($gql);
}
catch (QueryError $exception) {
// Catch query error and desplay error details
print_r($exception->getErrorDetails());
exit;
}
Display original response from endpoint
var_dump($results->getResponseObject());
Display part of the returned results of the object
var_dump($results->getData()->pokemon);
Reformat the results to an array and get the results of part of the array
$results->reformatResults(true);
print_r($results->getData()['data']);
Error I am getting
Fatal error: Uncaught Error: Class 'Mutation' not found in
C:\xampp\htdocs\dispoapi\index.php:21 Stack trace: #0 {main}
thrown in C:\xampp\htdocs\dispoapi\index.php on line 21
For me, the fix was to include the class, like this:
$gql = (new GraphQL\Mutation('Ping'))
Notice the "GraphQL\" in front of "Mutation"? If you don't setup an alias for "Mutation", then that has to be added in front of it.
Otherwise, this has to come after the "GraphQL" library include:
use GraphQL\Mutation;
Hi I'm integrating firebase PHP SDK in my codeigniter project and when I call my api then it's through error message :Call to a member function getReference() on null
My code is:
<?php
use Kreait\Firebase\Factory;
$factory = (new Factory)->withServiceAccount(APPPATH.'config/globaltaxi-277114-firebase-adminsdk-5s93b-2a0246ed22.json');
$database = $factory->createDatabase();
//$firebase->set($uri, $);
$ci = &get_instance();
function AddDriverToFirbase($uri, $driver_string)
{
$ci = &get_instance();
$firebaseDBComUrl = $ci->config->item('firebase_url');
$fireBaseNewRoomStorePath = $firebaseDBComUrl; //.$uri;
$database->getReference($fireBaseNewRoomStorePath)->getChild($uri)->set($driver_string);
}
and error response is
An uncaught Exception was encountered
Type: Error
Message: Call to a member function getReference() on null
anyone can you please help me for fix this issue. Thanks.
First I was check my php version and update sdk according version after that resolve all lib related issues.
There are issue found regarding uri and I need to update like below:
$database->getReference($uri)->set($driver_string);
Means no need for all url, just need to add node name which one we need to use for add our data.
I am attempting to generate a php-symfony server stub using swagger-codgen but I am not getting an index.php (or app.php or anything like that).
When I generate a server stub using the php-silex preset I get an index.php. If I google "silex .htaccess" I can easily find the mod_rewrite directives to get it working. However, when I generate code using the php-symfony preset I cannot find the entry point.
I attempted to combine the php-silex and php-symfony generated codebases (since silex is a symfony project) like so:
(index.php):
use Swagger\Server\Controller\GetTypesListController;
$app->GET('/image/list/types', function (Application $app, Request $request) {
$tlc = new GetTypesListController();
$response = $tlc->getTypeListAction($request);
return $response;
//new Response('How about implementing getTypeList as a GET method ?');
});
However, then I get errors like:
"Fatal error: Uncaught Error: Call to a member function getApiHandler() on null"
I modified the getApiHandler function of my generated GetTypesListController to instantiate the apiServer variable:
public function getApiHandler()
{
if (!isset($this->apiServer)){
$this->apiServer = new \Swagger\Server\Api\ApiServer();
}
return $this->apiServer->getApiHandler('getTypesList');
}
but this just gave me another error:
Undefined property: Swagger\Server\Controller\GetTypesListController::$container
(referencing SymfonyBundle-php/Controller/Controller.php on line 149)
I am obviously doing something wrong. I would really appreciate being pointed in the right direction.
Edit: I do realize that I'm not supposed to call controllers inside controllers.. I assume that I'm not supposed to combine these two generated codebases at all.
Problem statement:
I have to pass a php object from one php application to another using json. In my destination application, I am not able to access my member functions after json_decode.
Here is the sample script:
<?php
class TestScope{
private $privateVar;
function __construct(){
$this->privateVar="private";
}
function getPrivateVar(){
return $this->privateVar;
}
}
$testScope = new TestScope();
$encode = json_encode($testScope);
$decode = json_decode($encode);
print_r($decode->getPrivateVar());
?>
After executing the script, I am getting below error:
PHP Fatal error: Call to undefined method stdClass::getPrivateVar()
What is the possible solution to prevent this error?
What worked for me, was serializing and un-serializing the object(s) before putting them in cookies, sessions or databases.
I suppose it will work for this problem aswell:
http://php.net/manual/en/language.oop5.serialization.php
I was trying to implement some new functionality, decided not to, tried to roll back, and now am stuck with this error:
Fatal error: Call to a member function insert() on a non-object in /app/code/core/Mage/Core/Model/Mysql4/Resource.php on line 96
The functionality I mentioned seems simple enough (remove a couple links from the customer account sidebar), and I believe I've removed the 3 files and the edit to local.xml, but just for full view on things, here's exactly what i did.
Add'l info: I've got one custom module in place that I built for this site, and it was working prior to this glitch, but I'm wondering if something got screwed up in there maybe? (And I'm also thinking I might not have committed my last/working change, and now I'm in "doubt" territory about whether I screwed that up. It's a simple one though: 1 controller, 1 route.)
I've got no access to PHP error logs or the shell (exec() works great though), and the /var/system.log isn't adding anything more on my subsequent page-refreshes. And so this is where I'm stuck - Got any ideas on how to track this down? Thanks in advance!
Edit / here's the function that's throwing the error:
function setDbVersion($resName, $version)
{
$dbModuleInfo = array(
'code' => $resName,
'version' => $version,
);
if ($this->getDbVersion($resName)) {
self::$_versions[$resName] = $version;
$condition = $this->_write->quoteInto('code=?', $resName);
return $this->_write->update($this->_resTable, $dbModuleInfo, $condition);
}
else {
self::$_versions[$resName] = $version;
// this is line 96:
return $this->_write->insert($this->_resTable, $dbModuleInfo);
}
}