tags:

views:

731

answers:

4

I wonder there is a way to post a message to a facebook business page with cURL?

thanks

+3  A: 

here is roughly what you need without entirely doing it for you:

<?php
$poststring = "email=" . $email . "&pass=" . $password;
$ch = curl_init('http://www.facebook.com/pages/create.php');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "$poststring");
curl_exec ($ch);
curl_close ($ch);

You want to build on the &poststring variable. This is what will actually contain the information you are going to send. For each field in the form, you must put that field name in the string, and then populate it with the data you want.

A good way to find all those easily is to open up the page in firefox with the Web Developer Toolbar and it will show you every field that's used in the form, and what name it is.

Beware, to prevent spam there are lot of tokens and authentication stuff put in hidden fields to prevent abuse (which hopefully isn't what you're doing) and you will have to figure out how to generate or obtain that information.

Jeremy Morgan
+1 the the web dev toolbar, but I prefer firebug.com but just my opinion
RageZ
I think facebook might have an API to do that but never looked into it
RageZ
Hi Jeremy, thanks for your answer, but that is not what i want to do.I do not want to use cURL to create a new business page. I want to do is how to post a message to an existing business page.the code you post can not do want you want
David_214
What he showed you is how to do a post. You can apply his code to other POST's as well.
Geo
A: 

for now, I can update my facebook status with cURL, but when i try to post message to my business page, I got problem. with the same url address, the cURL code got the different page with the browser. I can not find out why it happens.

David_214
+1  A: 

Although just using curl sounds simpler, the most reliable and forward-compatible option is likely implementing Facebook's API (which happens to use a lot of curl itself...). Using the API you can call Stream.publish with your Page's ID as the target ID.

Ben
the problem of use facebook APT is I can not use API with out the facebook application
David_214
A: 

Does any one have anyother suggestion?

David_214