The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hi there...my company is in the midst of a proposal. One of the things that the client is interested in is the idea of sharing content with various partners of theirs . My client will be creating stories, articles and other fresh content daily and would like to sell the use of this content to their partners.

My question is how would I do that? They are basically wanting to be able to put a few lines of code onto the partner page and have it pull from our (my clients) database.

Is that possible? How would it be implemented in PHP/mySQL? I have seen it done before on sites like SlashDOT, Yahoo and the like and I thnk it is accomplised with XML, but how?

Any tutorials, suggestions, full code implementation or snide comments are welcome.

The first thing you want to do is provide B with a user id and password. They may want to be billed for item by item dled and even if they do not the customer will want to be able to justify fees with some actual count of article multiples delivered. This will allow them to identify who they are and you can check to make sure they are authorized to get the data (account current etc). Now the provide A, writes two content items for each article, a brief 3 line teaser and then the article. The teasers may be organized by A or B. But it is downloaded at predefined times daily. Here someone else could give an idea on how B may take the teasers and order them in a format on A prior to downloading. Now that the organized items are in place on B they may be readily accessed by C. An article click area for the the complete item will bring it to the designated location on the page.

Have site A (which contains all the content) generate a nice easy to parse text file dynamically somewhere on the site. For example if you were transferring news stories the text file couldbe formatted like this:

Code:

97887777||The Aliens have invaded!||Skunk||It was a terrible night last night as it was confirmed that aliens really have invaded earth...
97887777||Bill Gates buys Manhattan||creole||Microsoft last night announced that their headline deal to buy Manhattan from the US government had been given the go ahead by spineless congressmen...

Here's the file format:

TimeStamp||Headline||Author||News Story

Put a single news story on each line of the file in the above format. You'll have to make sure there are no line breaks anywhere in the story itself, but that can be easily achieved by replacing them all with <br> tags.

Now.... site B (the client server) has a CRON job which automattically retrieves the above text file via wget every 5 / 10 / 15 minutes (or however often you want it to) and saves it as a local copy on the server's file system. Site B can then run a simple PERL or PHP script on the file (which can also be sheduled by CRON) which breaks up the news stories and sticks them in a database. They can then be accessed by site B's content display system.

This is a very basic way of achieving what you want, but it should work just fine. If you want to get a bit more complicated you should look into generating an XML file on site A's server which Site B can then read and parse - this is a bit trickier but a lot more flexible in the long run.

Finally there's always Netscape's RDF format - I don't know anything about it but it's supposed to be pretty much the standard way of transferring news headlines between sites (slashdot.org uses it a lot for their custom news headline boxes down the right hand side).

Back to one of the items I mentioned. Each of the partners could be provided a partner number and that number be used in the same manner as the category in Kevin's tutorial. This would allow them to specify say Sports and Stocks, which would have their own id,s and the pull could be very easily customized. While it is coming out you could order (arrange) it in any fashion desired.

This really sounds like a neat project.

Oh and the Sports could be a seperate table, and one for each major header, Soccer, badmitton, horseshoes on a differnt level. Fast as all get-out.

a) MY company is going to be the only ones adding content. We will have some stuff to do every day, but some will be able to be scheduled (in advance entries you know).

All i want to do is to have the server run a CRON (or something similar) once a day. That CRON will access the database and write an .xml file (or something similar) containing all news stories for that day to the server. Then I write code for the affiliates to put on their site. They determine the format, we provide the content.

Does that make more sense?

I found several scripts on www.hotscripts.com that would probably do what I need. I will just have to learn how to implement them.

Wouldn't it just be easier to write a small script that could be passed info through the querystring, then just have them include that on their homepage? The script would simply go to the database, log in with a querystring specced username and password, and get querystring specced information. Then you could have a bunch of templates or something, and depending on the username and password it would use a certain template and print the output. It would also log the access into a file. You could then charge whoever is using this by the number of hits per day on the certain script, to make sure that you didn't get swamped by bandwith charges.

This way, there is very little programming involved, and you client only needs one line of code which you can send them. The only thing they need to give you is the template.

See, though, we want to provide this "code" to the affiliate so that they can implement it without any hassle on their part. I don't want a template for each affiliate, I just want them to get the news in their normal page.

In that case, perhaps, you could just have it spit out text, that they could put where they want. Even give them a list of querystring commands they could use to customize content. Or, you could just run a CRON job

I did the same thing, only for a different reason. I had forums run by CGI and I needed to have dynamic content which was updated by other sites to show their newest articles. I just wrote a PHP script to allow the different users to login, then each wrote to a different *.txt file.

I then exploded out different info and made a PHP script which got the data from different files depending upon what control I gave it. Worked like a charm. I could then include the new articles from other sites anywhere in my website, PHP or non .

Here is what I would do. If you are using a database, which I imagine you are, and I pray that the webmaster's you are dealing with are capable of manipulating data, then follow my madness, for there is method in't.

This is exactly what XML has been designed to achieve! - the transfer of data accross hetrogenous and distributed networks and platforms. That's the point for XML, you publish your data definition file and then anyone will be able to parse your XML into their web page, or whatever. I wish I had more experience and knowedge of XML. I really must learn it!

How you serve the data could be to cache it as a static file that gets updated periodically by running a crontab that generates the updated data. Or by calling a script that creates the data on demand.

Yep, this is exactly what XML was designed for. You create a DTD and then output the XML file, then the clients parse out whichever fields they want and display it however they feel like. http://www.w3schools.com has good info on DTD and XML.

w3schools is where I learned XML. Probably one of the better tutorials on XML. However I got bored quick but overall heres what I did learn. The first thing I did was make a brief list of articles found on my site:http://www.sohh.com/xml/list_articles.php