can someone help me with cURL?

xpro

Regular Member
Joined
Jan 21, 2009
Messages
442
Reaction score
24
Hello

I want to talk to someone that is experienced with curl. I'm able to login to facebook with it, but when I try to update status using POST the page comes up that I need to be logged in. Please PM me if you can help me and tell me what you want in return.

Best Regards!
 
I don't THINK you need to curl hack your way it to facebook just to post an update . . . thier is an api you can use . . . unless thier is some reason you do not wish to use the api . . . ? . . . anyway I am no CURL expert but you have to save the facebook login cookie into a session cookie in curl / just like in your browser . . . . if your browser can not send and receive cookies with the sever than the sever has no way of knowing that you are logged in. This feature is called curl_setopt

http://php.net/manual/en/function.curl-setopt.php
 
I don't THINK you need to curl hack your way it to facebook just to post an update . . . thier is an api you can use . . . unless thier is some reason you do not wish to use the api . . . ? . . . anyway I am no CURL expert but you have to save the facebook login cookie into a session cookie in curl / just like in your browser . . . . if your browser can not send and receive cookies with the sever than the sever has no way of knowing that you are logged in. This feature is called curl_setopt

http://php.net/manual/en/function.curl-setopt.php

I'm trying to post the status update for learning purposes only. And I think it am saving the cookie and sending it back, cause at first I go to Facebook.com get cookies and then use POST to login and passing the cookies as well.
 
Have you verified that you are indeed sending the correct cookie data with the status update POST? There are plenty of HTTP debuggers you can use to watch the requests go back and forth.
 
are you using two different curl variables for the two requests ? or closing the curl session between the two requsts ?
 
post up the code you are using . . . addtionally FB make hash their forums with a key of some forum to prevent this but honestly I don't know.

Are you setting a user agent in your Curl Code (tell FB what browser you are using)?

also try writing the code to use m.facebook.com AKA facebook mobile - Simplier interface designed to work with low-end phones that don't have javascript support in thier built in browsers
 
I can prob. help you in private but really dont wanna post the code out in public. Hit me in PM
 
post up the code you are using . . . addtionally FB make hash their forums with a key of some forum to prevent this but honestly I don't know.

Are you setting a user agent in your Curl Code (tell FB what browser you are using)?

also try writing the code to use m.facebook.com AKA facebook mobile - Simplier interface designed to work with low-end phones that don't have javascript support in thier built in browsers

I think it has to do with the key which is generated. I have to extract that and put that in the post string before I do the POST
 
This is from an early version of AAFA.

PHP:
function update_status($status) {
        
        $data = $this->curl_scrape ( "http://www.facebook.com/home.php?_fb_noscript=1" );
        if (totalStr ( strtolower ( $data ), "on your mind" ) !== 0) {
            
            preg_match ( "/name=\"fb_dtsg\" value=\"(.*?)\"/", $data, $fields ["fb_dtsg"] );
            preg_match ( "/name=\"profile_id\" value=\"(.*?)\"/", $data, $fields ["profile_id"] );
            preg_match ( "/name=\"composer_id\" value=\"(.*?)\"/", $data, $fields ["composer_id"] );
            preg_match ( "/name=\"target_id\" value=\"(.*?)\"/", $data, $fields ["target_id"] );
            preg_match ( "/name=\"post_form_id\" value=\"(.*?)\"/", $data, $fields ["post_form_id"] );
            
            $url = "http://www.facebook.com/ajax/updatestatus.php?__a=1";
            $string = "charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&fb_dtsg=" . $fields ['fb_dtsg'] [1] . "&composer_id=" . $fields ['composer_id'] [1] . "&profile_id=" . $fields ['profile_id'] [1] . "&target_id=0&display_context=home&status=" . urlencode ( $status ) . "&=Share&nctr[_mod]=pagelet_composer&post_form_id=" . $fields ['post_form_id'] [1] . "&post_form_id_source=AsyncRequest";
            
            $data = $this->curl_post ( $url, $string );
            
            if (totalStr ( $data, "error\":0" ) !== 0) {
                return array (true, $data, $string );
            } else {
                return array (false, $data, $string );
            }
        } else {
            return array (false, "No write access", $string );
        }
    }
 
Last edited:
Back
Top