How i can connect my server to the tally using PHP

A.J

I want to connect my server to the tally. The problem is that when I run this code in 'LOCALHOST' it is inserting data in the tally but when I am uploading that file to the server then it will not inserting the data can anyone help me. I think the problem is in URL I don't what URL I should give to run this code I am tried 'Domain_name.com' or 'Website IP address' it does not work. Can anyone help me out?


if(count($_POST)) {

    $group_name = strtoupper($_POST['group_name']);
    $item_name = $_POST['item_name'];
    /*$opening_balance = $_POST['opening_balance'];
    $opening_value = $_POST['opening_value'];
    $opening_rate = $opening_value * $opening_balance;*/

    $res_str =<<<XML
    <ENVELOPE>
<HEADER>
<TALLYREQUEST>Import Data</TALLYREQUEST>
</HEADER>
<BODY>
<IMPORTDATA>
<REQUESTDESC>
<REPORTNAME>All Masters</REPORTNAME>
</REQUESTDESC>
<REQUESTDATA>

<!-- Create Stock Group named "$group_name" -->
<TALLYMESSAGE xmlns:UDF="TallyUDF">
<STOCKGROUP NAME="{$group_name}" ACTION="Create">
<NAME.LIST>
<NAME>{$group_name}</NAME>
</NAME.LIST>
<PARENT/>
<ISADDABLE>Yes</ISADDABLE>
</STOCKGROUP>
</TALLYMESSAGE>

<!-- Create Stock Item named "$item_name" -->
<TALLYMESSAGE xmlns:UDF="TallyUDF">
<STOCKITEM NAME="{$item_name}" ACTION="Create">
<NAME.LIST>
<NAME>{$item_name}</NAME>
</NAME.LIST>
<PARENT>{$group_name}</PARENT>


<BATCHALLOCATIONS.LIST>
<NAME>Primary Batch</NAME>
<BATCHNAME>Primary Batch</BATCHNAME>
<GODOWNNAME>Main Location</GODOWNNAME>
<MFDON>20190120</MFDON>
<OPENINGBALANCE>0.000 NOS</OPENINGBALANCE>
<OPENINGVALUE>0.000</OPENINGVALUE>
<OPENINGRATE>0.000/NOS</OPENINGRATE>
</BATCHALLOCATIONS.LIST>
</STOCKITEM>
</TALLYMESSAGE>
</REQUESTDATA>
</IMPORTDATA>
</BODY>
</ENVELOPE>
XML;

    //var_dump($res_str);die;

    $url = "localhost:8000/";

        //setting the curl parameters.
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
// Following line is compulsary to add as it is:
        curl_setopt($ch, CURLOPT_POSTFIELDS,
                    "xmlRequest=" . $res_str);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
        $data = curl_exec($ch);

        if(curl_errno($ch)){
            var_dump($data);
        } else {
            $msg = $data;
        }
        curl_close($ch);


}

?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Tally</title>

    <!-- Bootstrap -->
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>


    <div class="container">

        <div class="col-md-6 col-md-offset-3" style="margin-top:20px">
            <?php if(isset($msg) && $msg) :?>
            <div class="alert alert-success" role="alert"><?=$msg?></div>
            <?php endif;?>
             <div class="pull-left"><a href="export.php">Item List</a> &nbsp;|&nbsp;</div>
              <div class="pull-left"><a href="stockGroupItem.php">Create StockGroup Item</a>&nbsp;|&nbsp;</div>
               <div class="pull-left"><a href="ledger.php">Create Ledger</a>&nbsp;|&nbsp;</div>
            <hr>

            <form class="form-horizontal" method="post" action="">
              <div class="form-group">
                <label for="group-name" class="col-sm-4 control-label">Stock Group name</label>
                <div class="col-sm-6">
                  <input type="text" class="form-control" id="group-name" placeholder="Stock Group name" name="group_name">
                </div>
              </div>
              <div class="form-group">
                <label for="item-name" class="col-sm-4 control-label">Stock Item name</label>
                <div class="col-sm-6">
                  <input type="text" class="form-control" id="item-name" placeholder="Stock Item name" name="item_name" required>
                </div>
              </div>

             <!--  <div class="form-group">
                <label for="opening_balance" class="col-sm-4 control-label">Quantity</label>
                <div class="col-sm-6">
                  <input type="text" class="form-control" id="opening_balance" placeholder="Item Quantity" name="opening_balance" required>
                </div>
              </div>

              <div class="form-group">
                <label for="opening_value" class="col-sm-4 control-label">Unit Price</label>
                <div class="col-sm-6">
                  <input type="text" class="form-control" id="opening_value" placeholder="Item Unit Price" name="opening_value" required>
                </div>
              </div> -->


              <div class="form-group">
                <div class="col-sm-offset-4 col-sm-6">
                  <button type="submit" class="btn btn-primary">Insert</button>
                </div>
              </div>
            </form>
        </div>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  </body>
</html>```
Mitalee Rao

The fact that it is working on your localhost URL means that you're running this html file on your local machine where Tally is installed. What happens if you put it up on the server? Your tally instance is running on your local machine, whereas your html file is on a server. Now your local machine has a LAN IP (say IP 192.x), which is hidden behind your main IP (say, A), which is assigned to your router. However, your server is at another IP (say, B).

How would the html file (at IP B) know how to ping Tally? Even if you gave the IP of your router (at IP A) instead of the localhost URL, how would the router know which of the machines on your LAN actually has Tally installed?

I ran this test using http://localhost.run/ where I allowed a port to be opened on the router (specifically localhost:9000 on my local machine, where Tally was running), and then I pinged Tally from the server by replacing the localhost URL with the url generated by this website.

You could try it for testing purposes, although in a production environment, you would probably need a more robust solution (either via SSH or by putting Tally itself on a server).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I connect my Flutter app to local sql server database using API?

How can I connect to my Amazon EC2 server using a desktop client

How can I connect to my server through SSH using only a browser?

How can I connect my Android app to Amazon RDS MySQL Database using Php?

How do I Connect to My Database Server Using MySQL Workbench?

I Can't connect to my server on localhost

How can i upload a video and a picture at the same time to a server using php and my sql

how can i upload image using react native expo image to my local server PHP / Database MySQL

Why can't I connect to my server using my public IP?

How can I connect php-apache and MySQL using Docker?

How can I connect to a API service using curl in php?

Failed to connect to database server. How do I connect to a database that is not on my localhost using powershell and integrated security?

How do I connect to my Notion API integration using .NET HttpClient? I can connect using Postman, but not my application

How can I connect my DataJoint LabBook instance to my DataJoint MySQL server?

How can I connect my springboot application to my redis server within the same kubernetes namespace?

How can I execute PHP in the background of my server?

How can I read .txt file from my server [PHP]?

Why I can't connect to a MySQL 5.3.36 shared server using mysqli_connect and PHP 7.4, but it will work using php 7.1?

I can not connect to my server sftp with ssh2_auth_password in php , but this work if I use FileZilla. This is my code :

Why can't I connect to my SQL Server with Windows Authentication using Domain Username?

I can't connect to my SQL Server database Using VB.NET

How can I activate my iTunes Connect?

How can I connect my index in list with for

How can i connect my page with Controller

How to I connect to an On-Prem SQL server using pyodbc using a Service Account (not my own AD account)

I can log into my sql server using php myadmin, but cant login using php

mongodump can't connect, how can I dump my mongodb dump without using mongodump

How can I connect an android with a local server?

How can I connect to the internet in Ubuntu server?