diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php index 100c6a99..ddf994bd 100644 --- a/bridges/FacebookBridge.php +++ b/bridges/FacebookBridge.php @@ -1,4 +1,5 @@ array( 'method' => 'POST', @@ -98,10 +100,11 @@ class FacebookBridge extends BridgeAbstract { ); $context = stream_context_create($http_options); $html = getContents($captcha_action, false, $context); + */ + list($html, $info, $res_header) = curlgetContents($captcha_action, $captcha_fields, true); + if ( $info['http_code'] != 200 ) + returnServerError('Error '.$info['http_code'].$captcha_action."\nReq:\n".$res_header."\nResp:\n".$info['request_header']); - if($html === false){ - returnServerError('Failed to submit captcha response back to Facebook'); - } unset($_SESSION['captcha_fields']); $html = str_get_html($html); } @@ -109,14 +112,16 @@ class FacebookBridge extends BridgeAbstract { unset($_SESSION['captcha_action']); } + $res_header = ''; //Retrieve page contents - if(is_null($html)){ - if(!strpos($this->getInput('u'), "/")){ - $html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('u')) . '?_fb_noscript=1') - or returnServerError('No results for this query.'); + if (is_null($html)) { + if (!strpos($this->getInput('u'), "/")) { + list($html, $info, $res_header) = curlgetSimpleHTMLDOM(self::URI.urlencode($this->getInput('u')).'?_fb_noscript=1'); + if ( $info['http_code'] != 200 ) + returnServerError('Error '.$info['http_code']."\nResp:\n".$res_header."\nReq:\n".$info['request_header']); } else { - $html = getSimpleHTMLDOM(self::URI . 'pages/' . $this->getInput('u') . '?_fb_noscript=1') - or returnServerError('No results for this query.'); + list($html, $info) = curlgetSimpleHTMLDOM(self::URI.'pages/'.$this->getInput('u').'?_fb_noscript=1'); + if ( $info['http_code'] != 200 ) returnServerError('No results for this query.'); } } @@ -172,6 +177,18 @@ EOD; // Ignore summary posts if(strpos($post->class, '_3xaf') !== false) continue; + // Determine post attachments + /* + $attachment_wrapper = $post->find('._3x-2')[0];// search for attachment + if ( isset($attachment_wrapper) ) { + $attachment = $attachment_wrapper->find('.mtm')[0]->children(0); + if ( strpos($attachment->class, '_2a2q') !== false ) { + // photos + } elseif ( strpos($attachment->class, '_6m2') !== false ) { + // link + } + }*/ + $item = array(); if(count($post->find('abbr')) > 0){ diff --git a/lib/contents.php b/lib/contents.php index 0d823ef2..3b436f74 100644 --- a/lib/contents.php +++ b/lib/contents.php @@ -30,6 +30,8 @@ $maxlen = null){ } else { $content = file_get_contents($url, $use_include_path, $context, $offset, $maxlen); } + date_default_timezone_set('CST'); + file_put_contents(__DIR__.'/../debug/D'.date('H-i-s').'.html', $content); if($content === false) debugMessage('Cant\'t download ' . $url); diff --git a/lib/contents_curl.php b/lib/contents_curl.php new file mode 100644 index 00000000..c545b811 --- /dev/null +++ b/lib/contents_curl.php @@ -0,0 +1,61 @@ +