how to recognise i am able to log in to rets ?
This is my code and output.
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
//date_default_timezone_set('America/New_York');
require_once("vendor/autoload.php");
//$log = new \Monolog\Logger('PHRETS');
//$log->pushHandler(new \Monolog\Handler\StreamHandler('php://stdout', \Monolog\Logger::DEBUG));
$config = new \PHRETS\Configuration;
$config->setLoginUrl('*****************');
$config->setUsername('****');
$config->setPassword('****');
$config->setUserAgent('****');
$config->setRetsVersion('1.7.2');
$config->setOption('disable_follow_location',false);
$config->setOption('use_post_method',true);
$rets = new \PHRETS\Session($config);
$rets->setLogger($log);
$connect = $rets->Login();
var_dump($connect->getBody());
output
Notice:
Trying to get property of non-object in
/var/www/html/glvar/rets/vendor/troydavisson/phrets/src/Parsers/GetMetadata/System.php
on line 26
Fatal error:
Call to a member function attributes() on a non-object in
/var/www/html/glvar/rets/vendor/troydavisson/phrets/src/Parsers/GetMetadata/System.php
on line 26
how can i know from this response that i am login in to rets and
i can get any data.
$config = new \PHRETS\Configuration;
$config ->setLoginUrl(***)
->setUsername(***)
->setPassword(***)
->setRetsVersion(***)
->setOption('use_post_method', false)
->setOption('disable_follow_location', false);
empty($user_agent') ? '' : $config->setUserAgent($user_agent);
empty($user_agent_password) ? '' : $config->setUserAgentPassword($user_agent_password);
$rets = new \PHRETS\Session($config);
$connect = $rets->Login();
if ($connect) {
echo " + Connected\n\n";
return $connect;
} else {
echo" + NotConnected\n\n";
}
Here is an ever better way to make sure.. add the code below you $connect and you should get something like the below.. and any response not an error should indicate a connection and show you what was returned..
$connect = $rets->Login();
print "<pre>";
print_r($connect);
print "</pre>";
This will be returned or some thing similar if you are connected..
PHRETS\Models\Bulletin Object
array {
[body:protected] =>
}
Watch out on the above answer.. I ran it on a live RETS feed and it stopped my program in its tracks.. and printed + Connected... I removed the return $connect and changed the \n to and it ran fine and printed Connected.. but my point is it may appear to work fine but the program will not go past the connection test... so it killed my program dead in its tracks... not sure why?
Related
One of my tiny program works smoothly on my lamp on pc. but when i did it on ubuntu vps, it rejects some pages or rejects some methods. Please help.
<?php
function Calc_ttlpay() {
$conn1 = new mysqli('localhost', 'root', 'mbimbi1979', 'men');
if (!$conn1) {
die('Could not connect to MySQL: ' . mysqli_connect_error());
}
$TTLsal=[];
$stmtTTL =$conn1->prepare("SELECT netsal FROM total_sif_view WHER Year
=?and month ? and visa = ? ");
$param1 = $_POST['year'];
$param2 = $_POST['month'];
$param3 = $_POST['visa'];
$stmtTTL->bind_param('sss',$param1,$param2,$param3);
$stmtTTL->execute();
$stmtTTL->store_result();
$TTLsal[1]=$stmtTTL->num_rows;
$TTL=0;
$stmtTTL->bind_result($ntsl);
while ($cresult=$stmtTTL->fetch()) {
$TTL=$TTL+$ntsl;
}
$TTLsal[0]=$TTL;
return $TTLsal;
}
Debug and it will tell you.
In your PHP file at the top after the opening <?php paste the code from below to turn on error reporting:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
If the above does not work on the server environment please put this into a php.ini file:
display_errors = on
See what if any errors that gives you. If something is missing it should tell you :)
Also try view source on the page as that can sometimes display where it breaks and why.
I had some errors in defining arrays. The method I used in test server enviro.. is not suitable for the production server, i.e.,$someVar = [ ] ; don't work on that Ubuntu PHP. So I made it like =array(); now everything is okay.
I'm using Factory in AngularJS, The Script is
app.factory('GetCountryService', function ($http, $q) {
return {
getCountry: function(str) {
// the $http API is based on the deferred/promise APIs exposed by the $q service
// so it returns a promise for us by default
var url = "https://www.bbminfo.com/sample.php?token="+str;
return $http.get(url)
.then(function(response) {
if (typeof response.data.records === 'object') {
return response.data.records;
} else {
// invalid response
return $q.reject(response.data.records);
}
}, function(response) {
// something went wrong
return $q.reject(response.data.records);
});
}
};
});
My Output Response Screen Shot:
My PHP Script:
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
session_start();
$ip = $_SERVER['REMOTE_ADDR'];
$dbname = "xyzData";
$link = mysql_connect("localhost", "Super", "Super") or die("Couldn't make connection.");
$db = mysql_select_db($dbname, $link) or die("Couldn't select database");
$uid = "";
$txt = 0;
$outp = "";
$data = file_get_contents("php://input");
$objData = json_decode($data);
if (isset($objData->token))
$uid = mysql_real_escape_string($objData[0]->token, $link);
else if(isset($_GET['uid']))
$uid = mysql_real_escape_string($_GET['uid']);
else
$txt += 1;
$outp ='{"records":[{"ID":"' . $objData->token . '"}]}';
echo($outp);
?>
I got error_log message is
[18-Mar-2016 21:40:40 America/Denver] PHP Notice: Trying to get
property of non-object in /home/sample.php
I tried both $objData->token and $objData->token[0]. But I got the same error notice. Kindly assist me...
I tried the Solution provided in the Post Notice: Trying to get property of non-object error, But it fails so, I raised 50 Bounty Points for this post. I tried to update my requirement in that post Question https://stackoverflow.com/review/suggested-edits/11690848, But the Edit was Rejected so I posted my requirement as a new Question. Kindly assist me...
The AngularJS is not sending any Object instead it passes the GET element.
Just access the Value by simply using $_GET['uid']
$objData doesn't seem to be an object.
try $objData['token'].
Or echo the object $objData and try to figure out what is its structure.
I've been using this over 2 months and worked fine until some days ago, when an error message appeared.
I use the steam api to get some info of the players.
$url = "http://steamcommunity.com/id/CGaKeepoN/?xml=1";
The page is not blank, it has an xml document. So my first thinking was that my host had turned allow_url_fopen off, but they don't (I asked them).
I also tried using error_reporting(E_ALL); ini_set('display_errors', 1);
And that's what I get:
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "" on line 6
Notice: Trying to get property of non-object on line 7
Now I'm using this: $xml = simplexml_load_file(file_get_contents($url));
And I would love to continue using it because installing cURL it's not an option right now. Do you know of a better (or a working) way to get this done? Or how to fix this error?
My full code:
error_reporting(E_ALL);
ini_set('display_errors', 1);
//$url = "http://steamcommunity.com/id/CGaKeepoN/?xml=1";
$url = "xml.txt";
ini_set('allow_url_fopen ','ON');
$xml = file_get_contents($url) or die ("file_get_contents failed");
$xml = simplexml_load_string($xml) or die ("simplexml_load_string failed");
$profilepic = $xml->avatarIcon;
$pic = $xml->avatarFull;
$steamID = $xml->steamID;
$lastonline = $xml->stateMessage;
echo $xml;
echo $profilepic;
echo $pic;
echo $steamID;
echo $lastonline;
EDIT:
If I use the internal url it loads the data, but when I try to use any url that uses http protocol just launches the file_get_contents failed error, even if the url is my website's one. I'm willing to use cURL if there's no other solution. I also thought about making a php script that loads the data and saves it in a file in the server (and then run a cronjob every 10 min), but it would use the file_get_contents anyway...
file_get_content returns a string so use simplexml_load_string instead.
This code works for me, tested.
$url = "http://steamcommunity.com/id/CGaKeepoN/?xml=1";
$xml = simplexml_load_string(file_get_contents($url));
$profilepic = $xml->avatarIcon;
$pic = $xml->avatarFull;
$steamID = $xml->steamID;
$lastonline = $xml->stateMessage;
var_dump($url);
var_dump($xml); //-> string(45) "http://steamcommunity.com/id/CGaKeepoN/?xml=1" bool(false)
echo $xml;
echo $profilepic;
echo $pic;
echo $steamID;
echo $lastonline;
I'm trying to get rid of a document by _id, but the PHP process stops without error, and no error in access.log, and no output if i assign a variable to remove(). Using mongodb:
version v2.4.9
$connection = new MongoClient();
if($connection == NULL) {
return "some msg";
}
$db = $connection->main;
$collection = $db->users;
$document = $collection->findOne(array('email' => $user->email));
if($document == NULL) {
// do some stuff, works fine.
} else {
$id = $document["_id"];
echo "id=".$id // outputs: 5469a22600a8ebe8418b4567
if($document["confirm"] != "true") {
echo "confirmed not true" // outputs fine
$collection->remove(array('_id' => new MongoId($id)), true);
echo "hello!"; // never occurs
}
}
EDIT: I tried this, and no output:
try {
$collection->remove(array('_id' => new MongoId($id)), true);
} catch(Exception $e) {
echo $e->getMessage();
}
EDIT: I found an answer, but I don't understand the answer because every example I've seen includes the true argument. So I won't self answer this question and leave it up to an expert.
This doesn't work:
$collection->remove(array('_id' => new MongoId($id)), true);
This doesn't work:
$collection->remove(array('_id' => new MongoId($id)), false);
This works:
$collection->remove(array('_id' => new MongoId($id)));
I can explain your problem but I cannot explain why you are not seeing errors, there must be something odd in your PHP setup.
Anyway, as to why your boolean only value for the second parameter does not work: it is because the PHP driver expects an array: http://php.net/manual/en/mongocollection.remove.php the examples you worked from were either incredibly old (Since the change happened 1.0.5 http://php.net/manual/en/mongocollection.remove.php#refsect1-mongocollection.remove-changelog) or incorrect.
I'm trying to get data from:
http://natomilcorp.com/api/get-users
But when I try it nothing is working.
$url = "http://natomilcorp.com/api/get-users";
$jsonString = file_get_contents($url);
$obj = json_decode($jsonString);
echo $obj->"username";
I try JQuery but I was not able to make it work.
I will like to get the username, lastseen and datejoined.
If someone could help me with this.
The things that could have gone wrong are:
The website is not responding
The JSON is invalid
There is some error in your code
This code should tell your what is happening:
error_reporting(-1); // Turn on error reporting
$url = "http://natomilcorp.com/api/get-users";
$jsonString = file_get_contents($url);
if ( ! $jsonString) {
die('Could not get data from: '.$url);
}
$obj = json_decode($jsonString);
if ( ! $obj) {
// See the following URL to figure out what the error is
// Be sure to look at the comments, as there is a compatibility
// function there
// http://php.net/manual/en/function.json-last-error-msg.php
die('Something is wrong with the JSON');
}
echo $obj->"username";