greater than symbol for find() method in php7 mongodb - mongodb

I am developing a php-mongodb project. I have installed the php-mongodb driver using composer. connectivity is working fine.
used reference link for any guidance :
http://mongodb.github.io/mongo-php-library/tutorial/crud/#crud-operations
and http://php.net/manual/en/mongocollection.find.php
I could not find much reliable theory for php-7 except those.
How to fire a query with php-7 to get a result from database greater than specified number?
The code I tried is :
$rs=$collection->find(['$gte'=>['avg'=>50]]);
this is not working. The error it produced was:
Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionException: unknown top level operator: $gte in /var/www/example.com/public_html/vendor/mongodb/mongodb/src/Operation/Find.php:180 Stack trace: #0 /var/www/example.com/public_html/vendor/mongodb/mongodb/src/Operation/Find.php(180): MongoDB\Driver\Server->executeQuery('training.tbl', Object(MongoDB\Driver\Query), Object(MongoDB\Driver\ReadPreference))#1 /var/www/example.com/public_html/vendor/mongodb/mongodb/src/Collection.php(437): MongoDB\Operation\Find->execute(Object(MongoDB\Driver\Server)) #2 /var/www/example.com/public_html/list.php(5): MongoDB\Collection->find(Array) #3 {main} thrown in /var/www/example.com/public_html/vendor/mongodb/mongodb/src/Operation/Find.php on line 180

found this answer from following here
// search for documents where 5 < x < 20
$rangeQuery = array('x' => array( '$gt' => 5, '$lt' => 20 ));
for above example the answer comes to be:
$rangeQuery = ['avg' => ['$gt' => '50' ]];
$rs=$collection->find($rangeQuery);

Related

Facebook PHP SDK "couldn't connect to host"

I'm trying to connect to facebook API
require_once '/composer/vendor/autoload.php';
$fb = new Facebook\Facebook([
'app_id' => 'xxxx', // obviously, I've put my app ID in here
'app_secret' => 'xxxx', // and my app secret in here
'default_graph_version' => 'v2.4',
]);
To do the following request, which, if I'm right, should give me the number of shares of the URL :
$target = 'http://stackoverflow.com';
$node = $fb->get('/?id='.urlencode($target).'&fields=share')->getGraphNode();
$shareCount = $node['share']['share_count'];
However, I get the following error :
Fatal error:
Uncaught exception 'Facebook\Exceptions\FacebookSDKException'
with message 'couldn't connect to host'
in /backend/composer/vendor/facebook/php-sdk-v4/src/Facebook/HttpClients/FacebookCurlHttpClient.php:83
Stack trace:
#0 /backend/composer/vendor/facebook/php-sdk-v4/src/Facebook/FacebookClient.php(216):
Facebook\HttpClients\FacebookCurlHttpClient->send('https://graph.f...', 'GET', '', Array, 60)
#1 /backend/composer/vendor/facebook/php-sdk-v4/src/Facebook/Facebook.php(504):
Facebook\FacebookClient->sendRequest(Object(Facebook\FacebookRequest))
#2 /backend/composer/vendor/facebook/php-sdk-v4/src/Facebook/Facebook.php(377):
Facebook\Facebook->sendRequest('GET', '/?id=http%3A%2F...', Array, NULL, NULL, NULL)
#3 /backend/the_script_i_am_currently_trying_to_run.php(79):
Facebook\Facebook->get('/?id=http%3A%2F...')
#4 {main} thrown in /backend/composer/vendor/facebook/php-sdk-v4/src/Facebook/HttpClients/FacebookCurlHttpClient.php on line 83
From what I have read, it could be that I'm not allowed to use cURL on my server, but I'm using it somewhere else and it works, so I don't think the problem comes from here.
Any idea of what I'm doing wrong ?
Thanks

There is no device with ID Using Zend and WURFL

I have integrate WURFL 1.6.0 with Zend every thing goes smooth it detects the desktop but in case of Android i am getting this error .On digging in deep i found out that my dir data/wurfl/cache is not loading with any data i have given it 777 permission but still it didnt work.
[25-Jun-2015 09:39:09] PHP Fatal error:
Uncaught exception 'Exception' with message 'There is no device with ID [generic_android_ver4_4] in the loaded WURFL Data' in /var/www/vhosts/mobiletocash.co.uk/httpdocs/library/wurfl-php-1.6.0.1/WURFL/CustomDeviceRepository.php:108
Stack trace:
#0 /var/www/vhosts/mobiletocash.co.uk/httpdocs/library/wurfl-php-1.6.0.1/WURFL/CustomDeviceRepository.php(211): WURFL_CustomDeviceRepository->getDevice('generic_android...')
#1 /var/www/vhosts/mobiletocash.co.uk/httpdocs/library/wurfl-php-1.6.0.1/WURFL/WURFLService.php(146): WURFL_CustomDeviceRepository->getDeviceHierarchy('generic_android...')
#2 /var/www/vhosts/mobiletocash.co.uk/httpdocs/library/wurfl-php-1.6.0.1/WURFL/WURFLService.php(62): WURFL_WURFLService->getWrappedDevice('generic_android...', Object(WURFL_Request_GenericRequest))
#3 /var/www/vhosts/mobiletocash.co.uk/httpdocs/library/wurfl-php-1.6.0.1/WURFL/WURFLManager.php(90): WURFL_WURFLService->getDeviceForRequest(Object(WURFL_Request_GenericRequest))
#4 /var/www/vhosts/mobiletocash.co.uk/httpdocs/library in /var/www/vhosts/mobiletocash.co.uk/httpdocs/library/wurfl-php-1.6.0.1/WURFL/CustomDeviceRepository.php on line 108
$resourcesDir = dirname(__FILE__) . '/../../data/wurfl/';
$wurfl['main-file'] = $resourcesDir . 'wurfl.xml';
$wurfl['patches'] = array($resourcesDir . 'web_browsers_patch.xml');
$cache['provider'] = 'Null';
//
$persistence['provider'] = 'File';
$persistence['dir'] = $resourcesDir . '/cache/';
$configuration['wurfl'] = $wurfl;
$configuration['persistence'] = $persistence;
$configuration['cache'] = $cache;
if i give $cache['provider'] = null;
it throws another exception . tried using $persistence['provider'] = 'file'; but no use
From what I can tell it does not look like the WURFL file is being properly loaded (perhaps the directory is not writeable) or is out of date. You most likely need to delete the persistence directory and reload the WURFL API.

Extbase can't use external PHP library

I am building a simple extension to display information on a Google Maps with Typo3.
I want to use the following PHP class (http://www.ycerdan.fr/developpement/google-maps-api-v3/) but I can't use it in my Controller.
I tried to use autoloading and require_once in my controller, but I just get PHP or Typo3 errors.
I guess it's a trivial problem, but I can't make it work despite lot of time searching.
Any help or hint are greatly appreciated ;)
General infos
Vendor name : CLICmap
Extension name : clicmap
Class location : Resources/Private/PHP
ext_autoloader.php :
$extensionPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('clicmap');
return array(
'gmaps' => $extensionPath.'Resources/Private/PHP/GoogleMapAPIv3.class.php',
);
How I use it in my controller
public function listAction() {
$maps = $this->mapRepository->findAll();
$gmaps = $this->objectManager->get('gmaps');
$this->view->assign('maps', $maps);
}
The PHP error :
Uncaught TYPO3 Exception
#1289386765: Could not analyse class:gmaps maybe not loaded or no autoloader? (More information)
TYPO3\CMS\Extbase\Object\Container\Exception\UnknownObjectException thrown in file
/var/www/html/ftypo3/typo3/sysext/extbase/Classes/Object/Container/ClassInfoFactory.php in line 37.
Trying require_once :
$extensionPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('clicmap');
require_once($extensionPath . 'Ressources/Private/PHP/GoogleMapAPIv3.class.php');
I get the following PHP error :
Warning: Uncaught exception 'TYPO3\CMS\Core\Error\Exception' with message 'PHP Warning: require_once(/var/www/html/ftypo3-fluid/typo3conf/ext/clicmap/Ressources/Private/PHP/GoogleMapAPIv3.class.php): failed to open stream: No such file or directory in /var/www/html/ftypo3/typo3conf/ext/clicmap/Classes/Controller/MapController.php line 52' in /var/www/html/ftypo3/typo3/sysext/core/Classes/Error/ErrorHandler.php:101 Stack trace: #0 /var/www/html/ftypo3/typo3conf/ext/clicmap/Classes/Controller/MapController.php(52): TYPO3\CMS\Core\Error\ErrorHandler->handleError(2, 'require_once(/v...', '/var/www/html/f...', 52, Array) #1 /var/www/html/ftypo3/typo3conf/ext/clicmap/Classes/Controller/MapController.php(52): CLICmap\Clicmap\Controller\MapController::listAction() #2 [internal function]: CLICmap\Clicmap\Controller\MapController->listAction() #3 /var/www/html/ftypo3/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php(286): call_user_func_array(Array, Array) #4 /var/www/html/ftypo3/typo3/sysext/extbase/Classes/Mvc/ in /var/www/html/ftypo3/typo3/sysext/core/Classes/Error/ErrorHandler.php on line 101
Fatal error: CLICmap\Clicmap\Controller\MapController::listAction(): Failed opening required '/var/www/html/ftypo3-fluid/typo3conf/ext/clicmap/Ressources/Private/PHP/GoogleMapAPIv3.class.php' (include_path='/var/www/html/ftypo3-fluid/typo3/contrib/pear/:.:/usr/share/php:/usr/share/pear') in /var/www/html/ftypo3/typo3conf/ext/clicmap/Classes/Controller/MapController.php on line 52
EDIT : Solved
The code that solved my problem in the controller :
require_once(PATH_site . 'typo3conf/ext/clicmap/Resources/Private/PHP/GoogleMapAPIv3.class.php');//OK
$gmap = new \GoogleMapAPI();
I was messing with the filepath and most importantly i hadn't put a \ before my class instanciation.
The code that solved my problem in the controller :
require_once(PATH_site . 'typo3conf/ext/clicmap/Resources/Private/PHP/GoogleMapAPIv3.class.php');//OK
$gmap = new \GoogleMapAPI();
I was messing with the filepath and most importantly i hadn't put a \ before my class instanciation.

Magento SOAP 2 API Fatal error: Procedure 'login' not present

I am getting: Fatal error: Procedure 'login' not present in /chroot/home/mystore/mystore.com/html/lib/Zend/Soap/Server.php on line 832
This is where the error is coming from
$soap = $this->_getSoap();
ob_start();
if($setRequestException instanceof Exception) {
// Send SOAP fault message if we've catched exception
$soap->fault("Sender", $setRequestException->getMessage());
} else {
try {
$soap->handle($request);
} catch (Exception $e) {
$fault = $this->fault($e);
$soap->fault($fault->faultcode, $fault->faultstring);
Any Ideas on how to fix the error?
I had the same issue, and which I did to fix it was to go to System/Configuration/Magento Core API and set the value WS-I Compliance as 'No'.
I'm working with a WebService which consumes the Magento V2 API, I don't recall if I generate the web reference using this value as 'Yes'; I'm working with a WS C# using VS 2010.
I had similar problem and I did not want to change the API version. Deleting the WSDL cache helped me.
Run this to get the WSDL cache folder:
php -i | grep soap
From the result you can see that the WDSL cache is enabled and stored in /tmp:
soap
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400
Remove the cache and run it again:
sudo rm -rf /tmp/*
I found the clue in this article - http://artur.ejsmont.org/blog/content/php-soap-error-procedure-xxx-not-present

mblox soap api - php soap Payment Request not working

mblox soap api - php soap Payment Request not working and gives error.
I use as below code in subscribe.php file...
$client = new SoapClient("https://ngp.us.mblox.com/client-gateway/services?wsdl", array('trace' => 1, 'encoding' => 'UTF-8', 'soap_version' => SOAP_1_2));
$array = array(
'SecurityContext'=>array('userId'=>'aaaaaaaa','password'=>'bbbbbbbb'),
'ClientDetails'=>array('shortcode'=>'234242', 'brandName'=>'aaaaaaaaaa.com', 'programSponsor'=>'aaaaaaaaaa', 'originatingUrl'=>'www.aaaaaaaaaa.com', 'minPageUrl'=>'www.aaaaaaaaaa.com', 'successUrl'=>'www.aaaaaaaaaa.com/subscribConfirm.php', 'cancelUrl'=>'www.aaaaaaaaaa.com', 'tcUrl'=>'www.aaaaaaaaaa.com/terms.html', 'postBackUrl'=>'http://aaaaaaaaaa/subscribe.php'),
'paymentDetails'=>array('paymentType'=>'PSMS', 'amount'=>'9.99', 'currency'=>'USD', 'billingFrequency'=>'MONTHLY'),
'msisdn'=>'243233232',
'serviceId'=>'332',
'operatorId'=>'33343',
'productDescription'=>'Text test',
'optInBody'=>'aaaaaaaaaa',
'browserSessionId'=>'123456',
);
$result = $client->initiatePayment($array);
It shows error as below on last line => $result = $client->initiatePayment($array);
Fatal error: Uncaught SoapFault exception: [(null)] in
/aaaaaaaa/Source/developement/PHP/ver1/subscribe.php:97 Stack trace:
0 /aaaaaaaa/Source/developement/PHP/ver1/subscribe.php(97): SoapClient->__call('initiatePayment', Array) #1
/aaaaaaaa/Source/developement/PHP/ver1/subscribe.php(97):
SoapClient->initiatePayment(Array) #2 {main} thrown in
/aaaaaaaa/Source/developement/PHP/ver1/subscribe.php on line 97
I got things working using curl,
I use This
as a reference and code working.
Thankx