Facebook like fetch url data using PHP Curl, Jquery and Ajax

Hi guys ..

Here I am going to share how to fetch/extract url datas like title , description and images from a website like facebook attach url module

I have used PHP curl to fetch the webpage content as a string. And I have used PHP Domdocument object to extract the meta title and description part.

Finally I have used preg_match_all function to fetch images from the webpage

here is the code below

[php][file]http://w3lessons.info/wp-content/uploads/2012/01/facebook-like-fetch-url-data.txt[/file][/php]

Check out my latest facebook scripts

  1. Facebook Style Youtube Video Expander with JQuery – http://w3lessons.info/2013/05/08/facebook-style-youtube-video-expanding-with-jquery/
  2. Facebook Style Wall Script 3.0 – http://w3lessons.info/2013/04/21/facebook-wall-script-3-0-timeline-oauth-location-sharing-smileys-many-more/

View Demo Download

You May Also Like

Never Miss Any Web Tutorials, Guides, Tips and Free eBooks

Join Our Community Of 50,000+ Web Lovers and get a weekly newsletter in your inbox

 

I hate spam too. Unsubscribe at any time.

38 thoughts on “Facebook like fetch url data using PHP Curl, Jquery and Ajax”

  1. Everything is very open with a clear explanation of the issues.
    It was definitely informative. Your website is very helpful.

    Thank you for sharing!

    Reply
  2. The demo currently didn’t work shows message ”

    Update Your Browser | Facebook
    ” .
    As I see it returns Title and description Only .
    I already have code that return only FaceBook upper and footer Div no page contents at all . I don’t know why but I think that data scrapped using Ajax o native Javascript codes .

    Reply
  3. The demo currently didn’t work shows message ”

    Update Your Browser | Facebook
    ” .
    As I see it returns Title and description Only .
    I already have code that return only FaceBook upper and footer Div no page contents at all . I don’t know why but I think that data scrapped using Ajax o native Javascript codes .

    Reply
  4. Hi,

    this is really nice script, but it is not working with the sites having slideshows or ajax data.
    Can you tell me resolution for same?

    thanks.

    Reply
  5. Its not working properly . In demo its working properly but when i download it and try to use , I give link in input field but its not fetching title , description and image also Please suggest .

    thank in advance

    Reply
  6. i think you site is going vary good, so i suggest you please quick change you wordpress site into core php site its is hackable by any one

    Reply
  7. Thanks for the code but it didn’t work.. It’s giving the following error:
    Fatal error: Call to undefined function curl_init() in D:AppServwwwelandzfacebook-like-fetch-url-datacurl_fetch.php on line 20

    Reply
  8. Same problem on my localhost … its showing few errors same as Khaljava …
    I have enabled my localhost for curl … but still the script is not working

    Reply
  9. Thanks for so quick reply.
    I don’t understand that example can run only on server. After uplouding it to my localhost (Vertrigo Server) it started work. But with errors

    Notice: Undefined variable: description in
    VertrigoServwwwcurl_fetch.php on line 69 and on line 91

    Reply
  10. I downloaded example, but it doesn’t work at all.
    After submitting FireBug sad that:

    Node cannot be inserted at the specified point in the hierarchy

    b[0]&&b[0].ownerDocument||c);var h=[],…a:a+”px”)}}),a.jQuery=a.$=f})(window);

    jquery-1.6.1.min.js

    Maybe jQuery not fresh?

    Reply
  11. Hi !!
    It’s very nice … thank you for this
    But I have some problems in this app
    this function curl_init(); … it don’t want to engaging … I use appserv 2.5.8 for Windows

    Reply
    • when you trying to open the file

      if you getting the following:
      Fatal error: Call to undefined function: curl_init()

      It is maybe for one of these reasons

      If this is with a hosting company, you will need to have them install/enable it.

      If this is a Windows based system, CURL can be enabled by uncommenting the curl extension line in the php.ini file – extension=php_curl.dll and restarting the web server.

      If this is Unix/Linux, PHP must be compiled with CURL support and the libcurl library must be installed.

      Reply
  12. Well done kartik…i have one doubt..currently i am working in .net,i need like this kind of extratcting url data other then PHP..can u help me to do? thanks in advance

    Reply

Leave a Comment