Jump to content

Help w/ php calling another website


rodin

Recommended Posts

Hello everyone,
  Just wondering if this were possible to do... Right now, I have a script that uses SigmaChat for my bulletin board, and it queries the remote server.. It works just great --- except when their server is offline.  This is my CURRENT php script called via cron every 5 minutes:

[code=php:0]
<?php include("http://client0.sigmachat.com/scwho.pl?id=xxxxxx&subroom=0&boldadmin=1&comma=1&countonly=0&chatbg=000000&chatusr=FFFFFF&subroomcolor=FFFFFF&chatadmusr=00FFFF&nousermsg=<smallfont>There+are+currently+no+users+in+chat.<%2Fsmallfont>"); ?>
[/code]

What i'm looking to do, is basically this:
If return value is sucessful, then write the contents to > test.html
if cannot connect to remote server, write "Chat Information Temporarily Unavailable" to >test.html

I currently call the scripts via cron by doing this:
*/5 * * * * root /usr/local/bin/php /home/user1/maint/numchat.php > /home/user1/maint/chat/numchat.html

Can anyone supply any help on getting this completed? Many thanks!
Link to comment
Share on other sites

im not quite sure what the result of that scipt you're calling is. but if you store that result in a variable you could write that value to your test.html doc by using the fopen(); fwrite(); and fclose(); functions.

[code]
$myFile = "test.html";
$fh = fopen($myFile, 'w') or die("can't open file");

$stringData = "Your contents.\n"; // where your contents are from that script you're calling.
fwrite($fh, $stringData);

$stringData = "Even more contents.\n"; // might need to append your contents while processing your data.
fwrite($fh, $stringData);

fclose($fh);
[/code]
results in test.html looking like:

Your contents.
Even more contents.
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.