ive seen lots of examples and to be honest i am a little confused on the matter.
I have been doing php for only 3 weeks so i am very new to this.
Basically i have wrote a function that asks for a token and a url, then it checks the database to if is exists, if it exists it then will offer a json array. I was wondering how select file and enter the function and retrieve the json data using cURL.
The function i have created is within the http://www.domain.com/api.php
Here is the function code:
function check_api_website($token, $url){
$token = trim(htmlentities($token));
$safetoken = mysql_real_escape_string($token);
$url = trim(htmlentities($url));
$safeurl = mysql_real_escape_string($url);
$checkwebsite = "SELECT message,islive FROM websitetokens WHERE url='".$safeurl."' AND token='".$safetoken."'";
$checkwebsite_result = mysql_query($checkwebsite) OR die();
$numberofrows = mysql_num_rows($checkwebsite_result);
if($numberofrows > 0){
$website = mysql_fetch_array($checkwebsite_result);
$message = stripslashes($website["message"]);
$islive = stripslashes($website["islive"]);
json_encode(array(
'message' => $message,
'islive' => $islive,
));
$date = date('Y-m-d');
$time = gmdate('H:i');
$loginwebsite = "UPDATE websitetokens SET loggedin='".$date."',time='".$time."' WHERE url='".$safeurl."' AND token='".$safetoken."'";
$loginwebsite_result = mysql_query($loginwebsite) OR die();
} else {
json_encode(array(
'message' => '',
'islive' => '1',
));
}
}
As you can see the json_encode is there and that is what i am wanting to retrieve.
If you could please explain a little also would help my learning.
Thanks for the help in advance :)