I want to fetch app data by package name in php - php

I am using google-play-scraper. but I am getting below error while using it.
Fatal error: Uncaught Error: Call to undefined method Symfony\Component\BrowserKit\Response::getStatus() in C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\raulr\google-play-scraper\src\Client.php:15 Stack trace: #0 C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\symfony\browser-kit\AbstractBrowser.php(401): Raulr\GooglePlayScraper\Client->filterResponse(Object(Symfony\Component\BrowserKit\Response)) #1 C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\raulr\google-play-scraper\src\Scraper.php(367): Symfony\Component\BrowserKit\AbstractBrowser->request('GET', 'https://play.go...') #2 C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\raulr\google-play-scraper\src\Scraper.php(108): Raulr\GooglePlayScraper\Scraper->request('/store/apps/det...', Array) #3 C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\examples\app.php(10): Raulr\GooglePlayScraper\Scraper->getApp('com.google.andr...') #4 {main} thrown in C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\raulr\google-play-scraper\src\Client.php on line 15
After getting this error I try the below solution.
Solution URL: https://github.com/raulr/google-play-scraper/issues/35
`[Change getStatus() to getStatusCode() ]
vendor\raulr\google-play-scraper\src\Client.php
Line: 15
$response->getStatus()
to
$response->getStatusCode()
vendor\raulr\google-play-scraper\src\Scraper.php
Line: 368
$status_code = $this->client->getResponse()->getStatus();
to
$status_code = $this->client->getResponse()->getStatusCode();`
but it did not work for me.

Related

Requests Operation is not working on Raw PHP

I have been trying to implement calling the specific API from the API I created. It is raw PHP, no framework is being used. Just a normal php file. Since I know that I have implemented the code right and tested few things on MAMP server, but the problem is Every time I try to call the API, I get 500 Internal Server Error.
I have downloaded the Requests.php file from this script from git: git clone git://github.com/rmccue/Requests.git
The file path is defined correct since I have reverified it.
Possibility is Request file is not getting implemented. Have included the Request file in my php file.
Code:
<?php
include('Applications/MAMP/htdocs/api/Requests/library/Requests.php');
$response = array();
$request_method = $_SERVER['REQUEST_METHOD'];
if( $request_method == 'GET' ){
Requests::register_autoloader();
$response = Requests::get('https://nut-case.s3.amazonaws.com/jobs.json');
echo $response;
}else {
echo 'No defined function for this method. Please use GET only';
}
?>
PHP Error Logs
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
[07-Jan-2020 13:26:51 UTC] PHP Fatal error: Uncaught Requests_Exception: cURL error 28: Operation timed out after 10000 milliseconds with 1131134 out of 1459668 bytes received in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php:422
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
[07-Jan-2020 13:27:04 UTC] PHP Fatal error: Uncaught Requests_Exception: cURL error 28: Operation timed out after 10000 milliseconds with 1113726 out of 1459668 bytes received in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php:422
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
[07-Jan-2020 13:28:02 UTC] PHP Fatal error: Uncaught Requests_Exception: cURL error 28: Operation timed out after 10000 milliseconds with 1096318 out of 1459668 bytes received in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php:422
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
[07-Jan-2020 13:28:16 UTC] PHP Fatal error: Uncaught Requests_Exception: cURL error 28: Operation timed out after 10000 milliseconds with 1113726 out of 1459668 bytes received in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php:422
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
The url is fine. I am trying my API on my localhost using MAMP, and the API is running fine. This is for testing purposes, since I am learning PHP for the first time. Please help. Thanks
Maybe you can try this to get the data.
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['phone_num'])) {
if (trim($_POST['phone_num']) != '') {
$ch = curl_init('https://nut-case.s3.amazonaws.com/jobs.json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // The number of seconds to wait while trying to connect. Use 0 to wait indefinitely.
curl_setopt($ch, CURLOPT_TIMEOUT, 30); // The maximum number of seconds to allow cURL functions to execute.
$data = curl_exec($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// Check if the request has status 200 ok
if ($httpStatus == 200) {
var_dump(json_decode($data));
} else {
//return an error
}
} else {
// return error invalid phone_num
}
}

Uncaught exception 'No_Result_Exception' with message 'No results'

I'm working with this codeigniter script called Crysandrea, anyways everything was going smoothly until I tried out the trading system.
Here is the error.
Fatal error: Uncaught exception 'No_Result_Exception' with message 'No results' in C:\xampp\htdocs\application\core\CRYS_Model.php:97
Stack trace: #0 C:\xampp\htdocs\application\core\CRYS_Model.php(190):
CRYS_Model->_process_result(Object(CI_DB_mysql_result), 1) #1
C:\xampp\htdocs\application\controllers\trades.php(535):
CRYS_Composite_Model->findRelation('3', '1', '*', Array) #2 [internal
function]: Trades->accept_trade('2') #3
C:\xampp\htdocs\system\core\CodeIgniter.php(359):
call_user_func_array(Array, Array) #4 C:\xampp\htdocs\index.php(203):
require_once('C:\xampp\htdocs...') #5 {main} thrown in
C:\xampp\htdocs\application\core\CRYS_Model.php on line 97
Here's the code for CRYS_Model.php
protected function _process_result(&$result, $limit=1) {
if (!$result->result_array())
throw new No_Result_Exception();
if ($limit === 1)
return $result->row(0, static::$INNER_MODEL);
else
return $result->result(static::$INNER_MODEL);
}
If you need anything, please say so!

Invalid JSON in influxdb-php

When a query is made, it retuns 404, invalid json error.
I use 8083 as port. Is there any another port for api.
Below is the code I use. Any help is welcome.
<?php
require '/vendor/autoload.php';
$client = new InfluxDB\Client('153.148.25.44', '8083');
$database = $client->selectDB('Meters');
$result = $database->getQueryBuilder()
->select('*')
->from('GDATA')
->limit(2)
->getResultSet()
->getPoints();
//$result = $database->query('select * from GDATAlimit LIMIT 5;');
//$points = $result->getPoints();
//$lastQuery = $client->getLastQuery();
echo '<pre>';
var_dump($result);
?>
Tested database connection, it is working.
Version is 0.13
Fatal error:
Uncaught exception 'InvalidArgumentException' with message 'Invalid JSON' in C:\xampp\htdocs\projectone\vendor\influxdb\influxdb-php\src\InfluxDB\ResultSet.php:30
Stack trace: #0 C:\xampp\htdocs\projectone\vendor\influxdb\influxdb-php\src\InfluxDB\Driver\Guzzle.php(100): InfluxDB\ResultSet->__construct('404 page not fo...')
#1 C:\xampp\htdocs\projectone\vendor\influxdb\influxdb-php\src\InfluxDB\Client.php(198): InfluxDB\Driver\Guzzle->query()
#2 C:\xampp\htdocs\projectone\vendor\influxdb\influxdb-php\src\InfluxDB\Database.php(78): InfluxDB\Client->query('Meters', 'SELECT * FROM "...', Array)
#3 C:\xampp\htdocs\projectone\vendor\influxdb\influxdb-php\src\InfluxDB\Query\Builder.php(261): InfluxDB\Database->query('SELECT * FROM "...')
#4 C:\xampp\htdocs\projectone\home.php(10): InfluxDB\Query\Builder->getResultSet()
#5 {main} thrown in C:\xampp\htdocs\projectone\vendor\influxdb\influxdb-php\src\InfluxDB\ResultSet.php on line 30
API port for InfuxDB v0.13 is 8086. I was using 8083, which is used for web.

Fatal Error, Zend Controller Response Exception

My Wordpress pages are returning this error to me:
Fatal error: Uncaught exception 'Zend_Controller_Response_Exception'
with message
'Cannot send headers; headers already sent in /home/memteaim/public_html/wp/wp-content/themes/memtea/core/library/class.layout.php, line 159'
in /home/memteaim/public_html/lib/Zend/Controller/Response/Abstract.php:321
Stack trace:
#0 /home/memteaim/public_html/lib/Zend/Controller/Response/Abstract.php(115): Zend_Controller_Response_Abstract->canSendHeaders(true) #1 /home/memteaim/public_html/app/code/core/Mage/Core/Model/App.php(1246): Zend_Controller_Response_Abstract->setHeader('Content-Type', 'text/html; char...')
#2 /home/memteaim/public_html/app/code/core/Mage/Core/Model/Cookie.php(93): Mage_Core_Model_App->getResponse()
#3 /home/memteaim/public_html/app/code/core/Mage/Core/Model/Cookie.php(209): Mage_Core_Model_Cookie->_getResponse()
#4 /home/memteaim/public_html/app/code/core/Mage/Core/Model/Cookie.php(260): Mage_Core_Model_Cookie->set('frontend', '9cc2ffcf7392261...', NULL, NULL, NULL, NULL, NULL)
#5 /home/memteaim/public_html/app/co in /home/memteaim/public_html/lib/Zend/Controller/Response/Abstract.php on line 321
Here is line 321 - 325 in my Abstract.php file:
throw new Zend_Controller_Response_Exception('Cannot send headers; headers already sent in ' . $file . ', line ' . $line);
}
return !$ok;
}
What's going on here and how do I fix it.
Any help would be amazing, thanks!

Fatal error: Uncaught exception 'Exception' with message 'Serialization of

Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php:138 Stack trace:
#0 C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php(138): session_write_close()
#1 [internal function]: CHttpSession->close()
#2 {main} Next exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php:138 Stack trace:
#0 C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php(0): session_write_close()
#1 [internal function]: CHttpSession->close()
#2 {main} Next exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php:138 Stack trace:
#0 C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php(0): session_write_close()
#1 [internal function]: CHttpSession->close()
#2 {ma in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php on line 138
how to fix this issue i'm unable to find any answer
I had the same error. I corrected it using an array of session
foreach ($output['tab_displayId'] as $id_display => $id_param){
$test = new ClParaWidget($id_param, $id_display);
$output[$id_display] = $test->toString($id_display);
if (Yii::app()->session['S' . $id_display] != $output[$id_display])
Yii::app()->session['S' . $id_display] = $output[$id_display];
}
I give more explanation. If I want to save in a session value an array:
Yii::app()->session['data'] = $array_data;
sometimes, this code returns an error:
Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php:138 Stack trace:
for that, I propose to use a array of session like here:
foreach ($array_data as $id => $data)
Yii::app()->session['S_' . $id] = $data;

Categories