I am using PHRETS Library to fetch the rets feed. At the time of image fetching its providing me the ErrorCode "20401". Object to fetch image from rets api as:
$objects = $rets->GetObject('Property', 'CmmlRntl', '75290', '*', 0);
foreach ($objects as $photo) {
$photo = $photo->getContent();
if($photo){
echo "<hr><pre>";
var_dump($photo);
//echo "<img src=\"data:image/jpeg;base64," . base64_encode('') . "\" />";
echo "</pre><hr>";
}
}
Output Getting As:
string '<RETS ReplyCode="20401" ReplyText="Requested Type not found." />' (length=64)
How i can get rid from this Error.?
I had the same issue, and couldn't find an answer to that problem, even after asking the MLS IT dept.
What I ended up doing was to have a cron that re-tries to fetch those images which I flag as 'failed', but the retry will is limited to 2 retries. If, after that, the image is still failing, then the retry script won't try to fetch it again.
For the most part, the error happened due to a failure on the MLS server, and usually I was able to fetch the image on the 2nd try.
Related
Sorry this may be a trivial question but I am new to PHP. In the documentation to retrieve project tasks, the following code is provided to connect to an Active Collab cloud account:
<?php
require_once '/path/to/vendor/autoload.php';
// Provide name of your company, name of the app that you are developing, your email address and password.
$authenticator = new \ActiveCollab\SDK\Authenticator\Cloud('ACME Inc', 'My Awesome Application', 'you#acmeinc.com', 'hard to guess, easy to remember');
// Show all Active Collab 5 and up account that this user has access to.
print_r($authenticator->getAccounts());
// Show user details (first name, last name and avatar URL).
print_r($authenticator->getUser());
// Issue a token for account #123456789.
$token = $authenticator->issueToken(123456789);
// Did we get it?
if ($token instanceof \ActiveCollab\SDK\TokenInterface) {
print $token->getUrl() . "\n";
print $token->getToken() . "\n";
} else {
print "Invalid response\n";
die();
}
This works fine. I can then create a client to make API calls:
$client = new \ActiveCollab\SDK\Client($token);
and get the list of tasks for a given project as shown in the documentation.
$client->get('projects/65/tasks'); // PHP object
My question is, what methods/attributes are available to get the list of tasks? I can print the object using print_r() (print will obviously not work), and what I really want is in the raw_response header. This is private however and I cannot access it. How do I actually get the list of tasks (ex: the raw_response either has a string or json object)?
Thanks in advance.
There are several methods to work with body:
$response = $client->get('projects/65/tasks');
// Will output raw JSON, as string.
$response->getBody();
// Will output parsed JSON, as associative array.
print_r($response->getJson());
For full list of available response methods, please check ResponseInterface.
If you wish to loop through tasks, use something like this:
$response = $client->get('projects/65/tasks');
$parsed_json = $response->getJson();
if (!empty($parsed_json['tasks'])) {
foreach ($parsed_json['tasks'] as $task) {
print $task['name'] . "\n"
}
}
I filter job offers on data from a database. As long as the table contained up to 10,000 records, everything worked great.
$searchQuery = \App\JobOffers::searchOffer($search_text, $search_location, $job_function, $job_type, $job_experience, $date_filter, $last);
Now the table has over 60,000 records with job offers. When I wants to perform filtering, the application returns error 500.
I can't find a solution to this problem.
I thought about using 'chunk'. I don't know if this solution will help.
foreach ($all->chunk(100) as $key => $chunk) {
$chunk = $chunk->all();
$test = $chunk::searchOffer($search_text, $search_location, $job_function, $job_type, $job_experience, $date_filter, $last);
$searchQuery->push($test);
}
In the above example I get an error: "Class name must be a valid object or a string".
Is there any way to solve this problem?
Here is the output as its beeing displayed right now in my index file (on the wesbite)
So this is what i have right now
https://gyazo.com/e3b5efb2c0ac9c7225c5c322ae92b0e9
And i want to have that displayed more nicley ( perhaps in a table with header from and then text )
That is my problem, im usure of what i can google or search for. Get the data that is saved in my json file. And Display it nicley in my index.
Get some of the values from my .json file and display them in my index.
Here is my php code.
$outfile= 'result.json';
$url='https://newsapi.org/v2/top-headlines?country=us&category=business&apiKey=MYAPIKEY';
$json = file_get_contents($url);
if($json) {
if(file_put_contents($outfile, $json, FILE_APPEND)) {
echo "Saved JSON fetched from “{$url}” as “{$outfile}”.";
}
else {
echo "Unable to save JSON to “{$outfile}”.";
}
}
else {
echo "Unable to fetch JSON from “{$url}”.";
}
$option = $_GET['option'];
And here its how i's getting displayed in my .json file.
{"status":"ok","totalResults":20,"articles":[{"source":{"id":"cnn","name":"CNN"},"author":"Matt McFarland","title":"Has Elon Musk lost control of his hype machine?","description":"For years, the entrepreneur controlled public opinion of Tesla. That's changing.","url":"https://money.cnn.com/2018/07/26/technology/elon-musk-tesla/index.html",
You might have invalid json response. verify first whether do you have valid json. May be copy your response and check it in some validator website like www.jsonlnt.com
if json is fine then PHP function json_decode($you_json_string_php_variable); will work fine.
I am trying to write an application that integrates with the Affiliate Window API. The only problem I have is I have literally 0 experience in php and so find myself unable to debug even the most elementary of issues.
I downloaded the below code which is supposed to be a sample application. Unfortunately running it fails at the first hurdle:
Invalid argument supplied for foreach() in /Users/ravinthambapillai/Downloads/api.client/listmerchants.php on line 9
This is the error message I get when I run the below:
Can anyone help me with what I need to fix to get this right?
<?php
define('API', 'PS');
require_once('constants.inc.php');
require_once('classes/class.ClientFactory.php');
$oClient = ClientFactory::getClient(REDACTED, REDACTED, merchant);
$listmerchants = array('iCategoryId'=> 97, 'iMaxResult' => 10);
echo 'hello world';
$oResponse= $oClient->call('getMerchantList', $listmerchants);
foreach($oResponse->oMerchant as $details){
$name = $details->sName;
$strapline = $details->sStrapline;
$description = $details->sDescription;
$logo = $details->sLogoUrl;
$showurl = $details->sDisplayUrl;
$deeplink = $details->sClickThroughUrl;
$id = $details->iId;
if ($logo<>'') {
echo "<a href=".$deeplink." title='".$name."'><img src=".$logo.
" style='float:left; margin:5px;' alt='".$name.
" :: ".$strapline." :: ".$description." :: ".$showurl.
"' width=\"88\" height=\"31\" border=\"0\"></a>";
}
}
?>
Did you update the constants in constants.inc.php?
API_USERNAME needs to be set to your account ID, and API_PASSWORD needs to be set to your Affiliate API Password as seen at https://www.affiliatewindow.com/affiliates/accountdetails.php (when you're logged in)
I'm doing an small class to load spreadsheets and insert data in them but when I insert a row i retrieve an error:
Expected response code 200, got 400 We're sorry, a server error
occurred. Please wait a bit and try reloading your spreadsheet.
I have looking in this site and google and some people has this error when they trying to insert data with capital letters or spaces... i'm not trying to insert data like this so i suppose that this is not my error. I the code that is giving me problems:
try {
echo $this->_spreadId . '<br>';
echo $this->_defaultWorksheetId . '<br>';
echo get_class($this->_spreadClient) . '<br>';
$rowData = array('stuff' => 'smurf');
$this->_spreadClient->insertRow($rowData, $this->_spreadId, $this->_defaultWorksheetId);
} catch (Exception $exc) {
echo '<br><pre>' . $exc->getTraceAsString() . '</pre>';
echo '<br>' . $exc->getMessage();
}
The output of this script is:
tVe4Mr82qD3LRhubQrcLxMQ
od6
Zend_Gdata_Spreadsheets
#0 /home/sergi/projects/quiniela2gdocs/lib/Zend/Gdata.php(219): Zend_Gdata_App->performHttpRequest('POST', 'https://spreads...', Array, 'performHttpRequest('POST', 'https://spreads...', Array, 'post('insertEntry('insertRow(Array, 'tVe4Mr82qD3LRhu...', 'od6')
Expected response code 200, got 400 We're sorry, a server error occurred. Please wait a bit and try reloading your spreadsheet.
Another method of this class is creating the spreadsheet and it's doing well, so i think there aren't connecting issues with gDocs.
Some help is welcome.
Lots of thanks !!
I had a similar problem which has arisen due to the presence of spaces in the array. Remove spaces helped me:
$rowData = array('stuff' => 'smurf'); - your code
$rowData = array('stuff'=>'smurf'); - my code