Jump to content

[SOLVED] "Gathering Code"


thecard

Recommended Posts

If someone signs up for my site, then they get a piece of code to put at the bottom of their website:

Something like this:

 

<? Include(‘www…./…php’); ?>

 

It includes a php file from my site into their site, it basically collects data from their site and stores it in my database and also echoes some output according to this data.

 

My problem:

 

I know that php doesn’t run on all websites, you have to buy special hosting.

How can I make it so that the code would run on all websites?

 

Will I have to use JavaScript?

I know its possible using javascript because of google adwords and Bitvertiser ads...

 

I'm really confused at the moment, I don't know how to think about solving this problem in the right way.

If you can't give me an answer, please point me to a tutorial or something...

 

Thanks for your time!

Link to comment
Share on other sites

well your right it is probably javascript because it is "supported" by all websites.. however.. your problem then will become wether or not users have it on..

 

your best bet would be to talk with the users who are implementing this.. and require they use php on their servers..

 

otherwise.. ya JS..

Link to comment
Share on other sites

Javascript is likely to be the best method - however it depends on what information you're trying to collect, etc.

 

One very basic example would be to simply build a request with the information you need, and format it like an URL Querystring:

 

OS=windows&userID=33&   ...

 

And then have your Javascript either use AJAX to request a special page on your site, or to create a new script tag, with the SRC of your special page:

 

Something like:

<script language="javascript" src="http://yoursite.com/special.php?QUERYSTRINGHERE

 

The users browser would attempt to get that page from your server, assuming they have Javascript turned on.

 

That page would process the items from the $_GET variables and could store them for you.

 

 

Sorry for the glossed-over example... ask about the parts you don't understand.

Link to comment
Share on other sites

How would I do this in JS?

Bad question, I know.

 

I know php and mysql preaty well -> is there away the "include" was in JS and that set off a script on my site collecting data from theirs?

 

Oh sorry -> I don't just want to collect data, I kinda need to print some results of queries too!

 

Ahh.

I made a mess of this!

Link to comment
Share on other sites

You don't need AJAX for this.  As someone else suggested use an IMG tag.

 

Your client inserts an IMG tag to a script on your page, complete with $_GET arguments.

<!-- your client's html code -->
<img style="display: none;" alt="Something or other" src="http://www.yoursite.com/clients/img.php?client_id=1&something_else=Larry" />

 

On your site you create the img.php script:

<?php
  // Grab $_GET['client_id'] and $_GET['something_else'] and do something with them.
  // doing something with the data...

  // This is supposed to be an image, so your script should dump out a 1x1 white img
  header( 'Content-type: image/gif' );
  // set more headers as appropriate
  fpassthru( 'path/to/1x1.gif' );
?>

 

(edit) If you need to get more fancy, think about creating a web service, which is very easy to do.  Do not rely on JavaScript (aka AJAX) solutions as the user can just disable JavaScript.

Link to comment
Share on other sites

That really is preety genius!

Just wondering if I could then echo text on to the user's page through that?

 

f you need to get more fancy, think about creating a web service, which is very easy to do.

 

I Googled Web services. Seems like just what I've been looking for.

How does Google Adwords do it?

Through Web Servicing?

 

Thanks for all you help.

Link to comment
Share on other sites

I can't speak for Google Adwords, but a web service is basically a way for you to create an API to your site that other people can interact with.  Amazon provides, or provided at one point, a web service to query book information from their site.  If you can find a working example of that or a tutorial on how to interact with it, it will give you a basic idea of what you can accomplish with a web service.

 

As for creating a web service of your own, it takes a little effort but if you have the PHP SOAP extension installed it takes care of most of the work for you.  The most difficult part is creating a proper WSDL file to describe the service; there are tools that can create a WSDL file for you but I prefer to make them by hand.

 

I can't really be much more help than that as I'm no expert on interoperability.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.