I am Using dominknow plateform from there they send a api hit on my server file and I get that data and store to mysql database .
All things are working find , but I am not able to send response back to that api that I have recevied the data correctly, so message is displaying "That your Pens package has not been sent to target location.
This type of response they wanted
https://demo.authr.it:A490CE33-CF8F-29B5-453D-D2A6482C54FD,HTTPStatus=200,error=0,error-text=collect (https://demo.authr.it:A490CE33-CF8F-29B5-453D-D2A6482C54FD,HTTPStatus=200,error=0,error-text=collect)
command received and
understood,version=1.0.0,pens-data={"generic":"https://share.cda.dominknow.one/e55c01eb58d4d8524272efe393e6c290/e710745c-5db9-3595-864f-75571171c3eb/xapi","url":"https://share.cda.dominknow.one/e55c01eb58d4d8524272efe393e6c290/e710745c-5db9-3595-864f-75571171c3eb/A490CE33-CF8F-29B5-453D-D2A6482C54FD"},
=================================
And this response they recieving from my below code, I dont know why error, error-text-version not being sent
https://mydemo.authr.it:6F095428-DD20-5278-7B92-56375FC4745E,HTTPStatus=200,error=,error-text=,version=,pens-data=
(https://mydemo.authr.it:6F095428-DD20-5278-7B92-56375FC4745E,HTTPStatus=200,error=,error-text=,version=,pens-data=)
=================================
$all_data=$_POST;
$file = fopen('/var/www/html/api/rec_file.txt', 'w');
fwrite($file,json_encode($all_data));
fclose($file);
$pens_version = $_POST['pens-version'];
?>
error=0
error-text=collect
version=<?php echo $pens_version; ?>
pens-data=
<?php
I believe you need to send a response in JSON.
header('Content-Type: application/json');
$response = array(
'error'=>0,
'error-text'=>'collect',
'version'=>$_POST['pens-version'],
'pens-data'=>''
);
echo json_encode($response);
The Response need to be in Plain Text as given below with PHP
header('Content: text/plain');
echo "error=0\r\n";
echo "error-text=collect\r\n";
echo "version=1.0.0\r\n";
echo "pens-data="
Related
I'm trying to output the status of a server (online/offline) in html.
I have a PHP snippet that checks the status of the server but I need the output to be in HTML format so I can use it elsewhere on my website.
I'm running wordpress with the tablera plugin, I want to output the status (just online or offline text) in the table but it does not accept PHP, only HTML.
Edit:
This is my PHP snippet:
<?php
$array="www.php.net:80";
$fp = #fsockopen($array[0], $array[1], $errno, $errstr,1);
if(!$fp){
$status = $array[0]."==><font color=\"#FF0000\">online</font>";
}
else{
$status = $array[0]."==><font color=\"#FF0000\">offline</font>";
}
fclose($fp);
echo $status;
?>
It just needs to check if the server is online or offline, if it's online it should display 'online' if its offline, it should display 'offline'.
This script checks your server to see if the server is online or not.
<?php
if (fsockopen('www.yourwebsite.com', 80)) {
echo('Reports Online');
} else {
echo('Reports Offline');
}
?>
I was working with tinder api. I would like to send messages to all matches in tinder accounts via tinder api. But I am getting getting http_code=500 error every time I wish to send the message to the matches. I also tried to update the bio and bio gets updated successfully but could not split the bio in different line feeds by passing \u000A in place of full stop. Does tinder support unicode?
My code snippet in php is as follows:
$data = callCurl("httxx://api.gotinder.com/user/recs", 'GET', $headers);
//print_r($data);
if (!empty($data['results']))
$profiles = $data['results'];
else
return("\nNo more recommendations\n");
foreach($profiles as $profile)
{
unset($profile['photos']);
//echo $profile["_id"];
$x=$x+1;
sleep(1);
$match = callCurl("httxx://api.gotinder.com/like/" . $profile["_id"], "GET", $headers);
//print_r($match);
$match = (bool)$match['match'];
if($match)
{
echo "\nMATCHED!!!!!!!!!!!\n";
$data_m_ = array("message"=> $message,
);
$msgres=callCurl("https://api.gotinder.com/user/matches/" . $profile["_id"], "POST", $headers, $data_m);
if($msgres['http_code']!=200)
echo "Message not sent"; // $msgres['http_code'] returns 500
}
echo ".";
if($x==100)
{
mysql_query("update tinder_accounts set account_status=1 where id='$blog_id_1'");
return("\n100 LIKES EXCEEDED.\n");
}
}
Kindly help on this issue for which I will be ever grateful to one who helps me. Thanks Krish
I cannot see if you send the auth tokens correctly but it seems you do not.
The headers from logging in to sending a message are different.
You need to send the x-auth headers as well on sending a message. Rest looks fine.
I tried with sending a GET request using ESP8266 wifi module using Arduino.The module successfully responded with :
SEND OK +IPD
On server, I want to receive the data and write it in a text file. So i tried the following codes
>parse_str( html_entity_decode( $_SERVER['QUERY_STRING']) , $out); $data= $out['data'];
$fileStatus=file_put_contents('myFile.txt',$data,FILE_APPEND);
if($fileStatus!=false){
echo "SUCCESS";
} else{ echo "FAIL"; }
But the data failed to store.
Assuming your GET request from the ESP to the server was made to the URL http://example.com/myPhpScript.php?parameter1=xxxx¶meter2=yyyy
you should be able to get the the value of parameter1 and paramter2 like this:
<?php
$p1 = $_GET['parameter1'];
$p2 = $_GET['parameter2'];
$data = $p1.','.$p2;
file_put_contents('myFile.txt',$data,FILE_APPEND);
?>
I have an that displays an interactive pdf form. How do I create a button to get data from the pdf document. Need help please, been on this the whole day.
Here's the php file that supposed to get the pdf data
if(isset($_POST) && is_array($_POST) && count($_POST)){
$data=array();
$data['topmostSubform[0].Page1[0].Applicant_Surname[0]']=$_POST['topmostSubform_0__Page1_0__Applicant_Surname_0_'];
$data['topmostSubform[0].Page1[0].Applicant_FirstName[0]']=$_POST['topmostSubform_0__Page1_0__Applicant_FirstName_0_'];
// need the function definition
require_once'createFDF.php';
// some variables to use
// file name will be <the current timestamp>.fdf
$kui = time();
/*$kui = time();*/
$fdf_file=$kui.'.fdf';
// the directory to write the result in
$fdf_dir=dirname(__FILE__).'/results';
// need to know what file the data will go into
$pdf_doc='http://localhost/uniApp/results/fillsheet.pdf';
// generate the file content
$fdf_data=createFDF($pdf_doc,$data);
// this is where you'd do any custom handling of the data
// if you wanted to put it in a database, email the
// FDF data, push ti back to the user with a header() call, etc.
// write the file out
if($fp=fopen($fdf_dir.'/'.$fdf_file,'w')){
fwrite($fp,$fdf_data,strlen($fdf_data));
/* echo $fdf_file,' written successfully.';*/
system("pdftk fillsheet.pdf fill_form results/". $fdf_file. " output results/$kui.pdf flatten");
$_SESSION['message'] = 'Your application has been updated';
$message = 'written successfully.';
echo $kui,' written successfully.';
}else{
die('Unable to create file:'.$fdf_dir.'/'.$fdf_file);
}
fclose($fp);
}
It works well when it using pure php code, but doesn't work when i try it from the <iframe>
I built a very basic webAPI that when called prints some json data on the screen.
I'm calling the api with the following
function getEnvironmentList(){
$fullUrl = "localhost/serverList/api/rest.php?action=allenvironments&format=json";
$jsonDataRaw = file_get_contents($fullUrl);
return $jsonDataRaw;
}
$jsonData = getEnvironmentList();
echo "<PRE>";
var_dump(json_decode($jsonData, true));
echo "</PRE>";
I get the error Warning: file_get_contents(localhost/serverList/api/rest.php?action=allenvironments&format=json): failed to open stream: No error in C:\path\inc\getJSONdata.php on line 6
Yet when I visit that URL I see this
{"1":{"environmentID":"1","envName":"UAT","envCreatedBy":"mhopkins","envCreatedDtTm":"2013-06-30 00:34:57","envUpdatedBy":"mhopkins","envUpdatedDtTm":"2013-06-30 00:34:57"},"3":{"environmentID":"3","envName":"Platinum","envCreatedBy":"mhopkins","envCreatedDtTm":"2013-06-30 00:37:38","envUpdatedBy":"phpsense","envUpdatedDtTm":"2013-06-30 00:37:38"}}
I'm really confused why the code can't seem to realize there is json data there...
You forgot the http.
$fullUrl = "http://localhost/serverList/api/rest.php?action=allenvironments&format=json";