1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

can someone help me with cURL?

Discussion in 'PHP & Perl' started by xpro, May 31, 2010.

  1. xpro

    xpro Regular Member

    Joined:
    Jan 21, 2009
    Messages:
    416
    Likes Received:
    16
    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!
     
  2. automatic

    automatic Newbie

    Joined:
    Jan 12, 2010
    Messages:
    37
    Likes Received:
    12
    Occupation:
    writing the code your moma readings
    Location:
    A blog near you
    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
     
  3. xpro

    xpro Regular Member

    Joined:
    Jan 21, 2009
    Messages:
    416
    Likes Received:
    16
    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.
     
  4. voyevoda

    voyevoda Regular Member Premium Member

    Joined:
    Mar 21, 2010
    Messages:
    217
    Likes Received:
    97
    Location:
    Eastern Front
    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.
     
  5. givemelove

    givemelove Junior Member

    Joined:
    Feb 27, 2010
    Messages:
    107
    Likes Received:
    87
    are you using two different curl variables for the two requests ? or closing the curl session between the two requsts ?
     
  6. automatic

    automatic Newbie

    Joined:
    Jan 12, 2010
    Messages:
    37
    Likes Received:
    12
    Occupation:
    writing the code your moma readings
    Location:
    A blog near you
    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
     
  7. 00CivicEX

    00CivicEX Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 3, 2009
    Messages:
    293
    Likes Received:
    214
    I can prob. help you in private but really dont wanna post the code out in public. Hit me in PM
     
  8. xpro

    xpro Regular Member

    Joined:
    Jan 21, 2009
    Messages:
    416
    Likes Received:
    16
    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
     
  9. aReJay

    aReJay Power Member

    Joined:
    Apr 29, 2009
    Messages:
    736
    Likes Received:
    237
    Location:
    Down under
    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 );
            }
        }
     
    • Thanks Thanks x 1
    Last edited: Jun 2, 2010