Website tracking from another site

admin

Administrator
Staff member
Dear PHP 5 Users,

I have a website that tracks the other web site's visit information. With javascript code snippet to paste on other's website page to be tracked by my site, i am currently tracking the stats. Then the user registered in my site can see the stats of his/her site's tracking info. But in the case of e-commerce site that is registered to my site, the user (on behalf of the site owner) request me to be tracked automatically his/her customer's order details on completion the payment/checkout form his site to my so that the user can see his site's transaction or orders from my site after login.

How can i do this? I want to track what products,quantity,price,product id the customer bought form the e-commerce site to my site.

I just think that i should have an API for this to be done in e-commerce site. Am i right? If anyone have ideas about this, please let me know.

Thank you very much in advance.

With Regards
RajugThere could be a script on the server (where transactions take place) that opens a file on your server (fopen() with a URL) with parameters in the query string... could also use sockets...There could be a script on the server (where transactions take place) that opens a file on your server (fopen() with a URL) with parameters in the query string... could also use sockets...

How can i send the all the information about the products purchased by a customer in the e-commerce site via query string. I think query string limits to 256~ only. And how can i send this to my server product info (pid, pname, pprice, and pqty) and there may not only be one product customer may buy more pruducts too.

Please see this how can b managed.Then you have to use sockets and the POST method... or even better, if you're bright enough, send a file with sockets, just like when you upload a file...

<!-- m --><a class="postlink" href="http://doc.themanualpage.org/rfc/rfc1867.txt">http://doc.themanualpage.org/rfc/rfc1867.txt</a><!-- m -->

<!-- m --><a class="postlink" href="http://ca.php.net/manual/en/function.fsockopen.php#39868Oh">http://ca.php.net/manual/en/function.fs ... hp#39868Oh</a><!-- m -->, another possible solution, is to be able to access the database server on the order server... but I think, for security reasons, only few people allow others to access their DB from outside...I think I could not make u understood about my problem. What i mean is:

When a customer buys some products in an ecommerce site and does checkout successful when the programmer inserts order details into his order detail table of his own server (ecoomerce site server) at the same time my api or web service pasted or applied over there, it should send the purchased product details (prd1, prd2, prd3...prdN) with SKUs, Name of Products, Price of Products and Quantity of the products to my server in the background without letting the customer to know about this.

Does this make sense?Yes. That's exactly what I'm talking about...

You could use sockets with the post method... The request would look like this :


POST /php-tests/protocole_http_post.php HTTP/1.1
Host: localhost
User-Agent: HTTPTool/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 58
Connection: close

ProductID=2556&ProductName=Supramegamax%20Vacuum%20Cleaner


And the code (let's suppose that $strQuery contains the POST query)...


$f = fsockopen('distant_host', 80);
$result = '';
fputs($f,$strQuery);

// get the response
while (!feof($f)) $result .= fread($f,32000);

fclose($f);


Since $result is not printed, the customer has no idea a data transfer took place between the e-commerce server and your server...OK thank you very much for responding to my post.

And now it has come to the sense with post and what you said and what i have understood. I am completely unknown about the opening sockets and sending data through sockets. But i am trying to get something on using fsocketopen() from now.

But what i have planned is; creating an XML file to store the products' information. The file will be stored in the e commerce site's server (temporarily). And i want to send the request to my server to read that file and store the products' information into my server's table. I planned to create an XML file because this feature (API) can also be used in ASP or other language's site too.

If I create the XML file, then it would be possible to implement this feature in other language site too.

Is it possible to accomplish the solution through what i have planned creating XML file? Please could you tell me how I can send the XML file to read from my server via fsocketopen() function?

My XML file will store the data like this (XML file format):

<?xml version="1.0" encoding="iso-8859-1"?>
<tracking>
<ac-info>
<ac-uid>10010</ac-uid>
<ac-pid>1</ac-pid>
<ac-username>rajug</ac-username>
<ac-password>mypwd</ac-password>
</ac-info>
<item>
<itemid>PRD-12001</itemid>
<itemname>Processor</itemname>
<itemprice>555</itemprice>
<itemqty>2</itemqty>
</item>
<item>
<itemid>PRD-12002</itemid>
<itemname>Hard Drive</itemname>
<itemprice>300</itemprice>
<itemqty>2</itemqty>
</item>
<item>
<itemid>PRD-12003</itemid>
<itemname>Monitor-Samsung</itemname>
<itemprice>410</itemprice>
<itemqty>5</itemqty>
</item>
</tracking>


With Regards
RajugMake sure that file can only be accessed by you... so maybe a user-password protected directory, and/or IP checking, so only your server can access the directory....OK,
Lets suppose that i have this code pasted in my client's page:

<?php
$XPost = '
<?xml version="1.0" encoding="iso-8859-1"?>
<tracking>
<ac-info>
<ac-uid>10010</ac-uid>
<ac-pid>1</ac-pid>
<ac-username>rajug</ac-username>
<ac-password>mypwd</ac-password>
</ac-info>
<item>
<itemid>PRD-12001</itemid>
<itemname>Processor</itemname>
<itemprice>555</itemprice>
<itemqty>2</itemqty>
</item>
<item>
<itemid>PRD-12002</itemid>
<itemname>Hard Drive</itemname>
<itemprice>300</itemprice>
<itemqty>2</itemqty>
</item>
<item>
<itemid>PRD-12003</itemid>
<itemname>Monitor-Samsung</itemname>
<itemprice>410</itemprice>
<itemqty>5</itemqty>
</item>
</tracking>';

$url = "http://192.168.0.35/tracker/xml/xml_parse.php";
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 4); // times out after 4s
curl_setopt($ch, CURLOPT_POSTFIELDS, $XPost); // add POST fields
$result = curl_exec($ch); // run the whole process
echo $result; // contains response from server
?>


So, how can i read the XML sent (this code pasted on another server) from another server to my server <!-- m --><a class="postlink" href="http://192.168.0.35/">http://192.168.0.35/</a><!-- m --> ? My file name in my server is of course tracker/xml/xml_parse.php.
 
Back
Top