How would I use php to make forum posts on other sites?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
coondog
Forum Newbie
Posts: 5
Joined: Mon Jul 14, 2008 9:48 am

How would I use php to make forum posts on other sites?

Post by coondog »

how would i use php to make forum posts on other sites?

like logging into a site, storing a cookie(s) and then sending post data
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: How would I use php to make forum posts on other sites?

Post by pickle »

Why would you want to do that? Seems a lot like a way to create lots of SPAM?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Dynamis
Forum Contributor
Posts: 122
Joined: Thu Jul 10, 2008 3:15 pm
Location: Indiana, US

Re: How would I use php to make forum posts on other sites?

Post by Dynamis »

I made something of this nature a few years back. As far as I know though, you must log into each webpage that you want to post on first, and then you can post to them from your site. So one possible way of doing it would be to include all the other webpage logins on your page, log into all the sites you want to post on, and then have a form on your site that you could fill out and would submit to the correct site(s).

Also, you can get the form action tags from the page source of the webpages that you want to post on.
coondog
Forum Newbie
Posts: 5
Joined: Mon Jul 14, 2008 9:48 am

Re: How would I use php to make forum posts on other sites?

Post by coondog »

pickle wrote:Why would you want to do that? Seems a lot like a way to create lots of SPAM?
don't worry pickle, I could contact the other forum(s) and ask them if it's alright first.
but there are various ways this kind of stuff could be used, for one you could use it like if you had a network of forums and wanted to post on them all for when you make announcements

is there a function you can use in PHP to store a cookie on the host server and a function to send post data to a different server?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: How would I use php to make forum posts on other sites?

Post by pickle »

cURL
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Dynamis
Forum Contributor
Posts: 122
Joined: Thu Jul 10, 2008 3:15 pm
Location: Indiana, US

Re: How would I use php to make forum posts on other sites?

Post by Dynamis »

To send post data to a different server, you just put the server process page in your form action tag.

Example: http://www.example.com/index.php has a form you want to submit to. Upon viewing the page source you find <form action="process.php" ...
So based on this, your form on your site should be

<form action="www.example.com/process.php" ..

This will make process.php on http://www.example.com process your form upon submission.
coondog
Forum Newbie
Posts: 5
Joined: Mon Jul 14, 2008 9:48 am

Re: How would I use php to make forum posts on other sites?

Post by coondog »

Dynamis, sending post data isn't too hard, but how do I retrieve cookies?
Dynamis
Forum Contributor
Posts: 122
Joined: Thu Jul 10, 2008 3:15 pm
Location: Indiana, US

Re: How would I use php to make forum posts on other sites?

Post by Dynamis »

I guess I'm not sure what you are trying to do then. Why do you need to retrieve a cookie? If you are just posting onto another site, you shouldn't need to mess with cookies, and not all sites use cookies anyway, so this would not be efficient.
coondog
Forum Newbie
Posts: 5
Joined: Mon Jul 14, 2008 9:48 am

Re: How would I use php to make forum posts on other sites?

Post by coondog »

well you have to be logged into atleast one of the sites, so just sending post data isn't enough, I need to use cookies
Dynamis
Forum Contributor
Posts: 122
Joined: Thu Jul 10, 2008 3:15 pm
Location: Indiana, US

Re: How would I use php to make forum posts on other sites?

Post by Dynamis »

Is including the page log-in in a tiny port of your page not what you are looking to do? No matter what you are going to have to log in to the webpage. So if you include the log-in in an iframe on your page, then once you log in to the site on your page, you should be able to post. This way you need not do anything with cookies. Would this suit what you need? Need an example?
coondog
Forum Newbie
Posts: 5
Joined: Mon Jul 14, 2008 9:48 am

Re: How would I use php to make forum posts on other sites?

Post by coondog »

I don't mean to have the cookies stored on the client computer(like my computer), but instead on the server computer
Dynamis
Forum Contributor
Posts: 122
Joined: Thu Jul 10, 2008 3:15 pm
Location: Indiana, US

Re: How would I use php to make forum posts on other sites?

Post by Dynamis »

By including the login in an iframe on your page, once you log in on there, you can do anything on your page and still be logged into that website. So posting to their site would work. Its just like you could go to their site, log in, go back to your site and still post because you would still be considered logged in, in most cases, until you close your browser.

So, you didn't really answer my question but I think I answered yours. The two ways I know this will work are:
1. Include their login on your page in an iframe. This will allow you to log in on your page, to their page, and then immediately post from your page to their site.
2. Go to their site, log in, go back to your site, and then post to their site. This works w/ cookies for sure, not 100% on sessions though. May need to use option 1 for sessions.

Does that help? If not, please go into more detail with what you want to do.
Post Reply