Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts

    Curl - saving complete webpage into a variable

    I have this code

    PHP Code:
    curl_setopt($chCURLOPT_POST0);
    curl_setopt($chCURLOPT_URL$link);
    $wall curl_exec($ch); 
    but the $link is a facebook wall page that takes a couple of seconds to load fully. and you have to scroll down the page before more loads or you have to click older posts

    when i run the script the $wall doesnt have the full page.

    Is there a way that i can delay the $link from saving the file so that it reads more of the page??
    Last edited by kevinkhan; 03-01-2012 at 01:46 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Curl shouldn't be resuming its control to the script until either its timed out or its complete. You may want to check first if it returns a 200, if it does then that sounds like its working fine. Otherwise, you can set a new option for CURLOPT_TIMEOUT in the number of seconds.
    Are you sure its not javascript that's populating the wall? Sounds to me like you are trying to wait for the javascript.

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,530
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Yup, Facebook populates and extends its wall with javascript, so this method won't work.

    If you want to grab a wall, the Facebook API does that just fine.

  • #4
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Curl shouldn't be resuming its control to the script until either its timed out or its complete. You may want to check first if it returns a 200, if it does then that sounds like its working fine. Otherwise, you can set a new option for CURLOPT_TIMEOUT in the number of seconds.
    Are you sure its not javascript that's populating the wall? Sounds to me like you are trying to wait for the javascript.
    yes its waiting for js to load. but i think the curl is saving the page to quickley

    does the facebook api allow you to save content from a wall of none friends?

    and can somebody point in to a link where i can read about the api.

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by kevinkhan View Post
    yes its waiting for js to load. but i think the curl is saving the page to quickley

    does the facebook api allow you to save content from a wall of none friends?

    and can somebody point in to a link where i can read about the api.
    Can't help you with the facebook api, but I'm sure they would accommodate this. Unless you write an ECMA parser yourself, JS will not execute when retrieved by curl.

  • #6
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,530
    Thanks
    45
    Thanked 259 Times in 256 Posts
    For the facebook API, just google "Facebook API". Plenty of pages.

    And no, the API only allows you to pull wall posts that are public or give you permission (as a friend or as an app).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •