user758939
user758939

Reputation: 1

Using PHP Curl to download a webpage in the logged in State

I have been trying to get facebook page's contents using PHP Curl. But even if i am logged into facebook from my browser , the page which the CUR session returns requests for login id an password . I think its some issue of ccokies which I dont know. Please help how to send the cookies stored in my browser in the CURL request.

Upvotes: 0

Views: 273

Answers (1)

James C
James C

Reputation: 14149

As with most websites Facebook uses cookie based sessions to keep you authenticated.

You'll need to get your CURL script to authenticate to Facebook and then scrape the data that you're after. When you do this you'll need to make sure that the cookies are stored across the different (auth and then following requests) by using a "cookie jar". If you look in the PHP CURL documentation they explain how to use a cookie jar and persist cookies across multiple requests.

I'm not sure what data you're trying to fetch but I think you're likely to do better using Facebook's API to fetch the data. APIs are designed for machines/processes to fetch data, whereas the website is there for people to view. If you use the API you won't have to scrap the data out from within the page/display.

Upvotes: 1

Related Questions