Quantcast
Channel: Dạy Nhau Học - Latest topics
Viewing all articles
Browse latest Browse all 34351

Curl facebook.com bản desktop bị lỗi

$
0
0

@Duy_Hoang98 wrote:

hi mn, em thử curl với facebook bản mobile (m.facebook.com) thì get được dữ liệu đúng như khi mình truy cập link đó ở trình duyệt, nhưng khi curl bản desktop www.facebook.com thì nó sẽ luôn bị như này

ví dụ link trang cá nhân của zuck: https://www.facebook.com/zuck , khi curl link nafykết quả sẽ bị như bên dưới. nhưng curl https://m.facebook.com/zuck thì được

không biết là facebook chặn hay là do gì nữa, ai biết ko ạ.

code day a

$url = 'https://www.facebook.com/zuck';
$cookie = '';// cookie facebook
echo postData('https://www.facebook.com/zuck', $cookie); //error
echo postData('https://m.facebook.com/zuck', $cookie); //ok
echo postData('https://mbasic.facebook.com/zuck', $cookie, 'mobile'); //ok
function postData($url, $cookie = null, $type = 'desktop')
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    if ($cookie != null) {
        curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    }
    if ($type == 'mobile') {
        curl_setopt($ch, CURLOPT_USERAGENT, 'Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14');
    } else {
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36');
    }
   
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 34351

Latest Images

Trending Articles