@@ -42,7 +42,7 @@ public function sendMessage(string $message): bool {
4242 return $ ret ;
4343 });
4444 $ postfields = $ postfields ();
45- //seems facebook removed this field: assert ( array_key_exists ( 'name', $postfields ) );
45+ // seems facebook removed this field: assert ( array_key_exists ( 'name', $postfields ) );
4646 assert ( array_key_exists ( 'body ' , $ postfields ) );
4747 $ postfields ['body ' ] = $ message ;
4848 $ urlinfo = \parse_url ( $ hc ->getinfo ( CURLINFO_EFFECTIVE_URL ) );
@@ -51,12 +51,12 @@ public function sendMessage(string $message): bool {
5151 // hhb_var_dump ( $postfields, $posturl );
5252 $ hc ->setopt_array ( array (
5353 CURLOPT_POST => true ,
54- CURLOPT_POSTFIELDS => http_build_query ( $ postfields )
54+ CURLOPT_POSTFIELDS => http_build_query ( $ postfields )
5555 ) );
5656 $ hc ->exec ( $ posturl );
5757 // TODO: parse the response to make sure it isn't an error?
5858 // hhb_var_dump ( $postfields, $posturl, $hc->getStdErr (), $hc->getResponseBody () );
59-
59+
6060 return true ;
6161 }
6262 public function getRecipient (): string {
@@ -86,12 +86,13 @@ function __construct() {
8686 $ hc ->setopt_array ( array (
8787 CURLOPT_USERAGENT => 'Mozilla/5.0 (BlackBerry; U; BlackBerry 9300; en) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.570 Mobile Safari/534.8+ ' ,
8888 CURLOPT_HTTPHEADER => array (
89- 'accept-language:en-US,en;q=0.8 '
90- )
89+ 'accept-language:en-US,en;q=0.8 '
90+ )
9191 ) );
9292 $ hc ->exec ( 'https://m.facebook.com/ ' );
93+ // \hhb_var_dump ( $hc->getStdErr (), $hc->getStdOut () ) & die ();
9394 $ domd = @\DOMDocument::loadHTML ( $ hc ->getResponseBody () );
94-
95+
9596 $ namespaces = array ();
9697 foreach ( \get_declared_classes () as $ name ) {
9798 if (\preg_match_all ( "@[^ \\\]+(?= \\\)@iU " , $ name , $ matches )) {
@@ -102,14 +103,13 @@ function __construct() {
102103 if (! isset ( $ parent [$ match ] ) && \count ( $ matches ))
103104 $ parent [$ match ] = array ();
104105 $ parent = &$ parent [$ match ];
105-
106106 }
107107 }
108108 }
109-
109+
110110 // print_r ( $namespaces );
111111 // die ( "DIEDS" );
112-
112+
113113 $ form = (\MsgMe \tools \getDOMDocumentFormInputs ( $ domd , true )) ['login_form ' ];
114114 $ url = $ domd ->getElementsByTagName ( "form " )->item ( 0 )->getAttribute ( "action " );
115115 $ postfields = (function () use (&$ form ): array {
@@ -128,11 +128,24 @@ function __construct() {
128128 CURLOPT_POST => true ,
129129 CURLOPT_POSTFIELDS => http_build_query ( $ postfields ),
130130 CURLOPT_HTTPHEADER => array (
131- 'accept-language:en-US,en;q=0.8 '
132- )
131+ 'accept-language:en-US,en;q=0.8 '
132+ )
133133 ) );
134+ // \hhb_var_dump ($postfields ) & die ();
134135 $ hc ->exec ( $ url );
136+ // \hhb_var_dump ( $hc->getStdErr (), $hc->getStdOut () ) & die ();
137+
135138 $ domd = @\DOMDocument::loadHTML ( $ hc ->getResponseBody () );
139+ $ xp = new \DOMXPath ( $ domd );
140+ $ InstallFacebookAppRequest = $ xp ->query ( "//a[contains(@href,'/login/save-device/cancel/')] " );
141+ if ($ InstallFacebookAppRequest ->length > 0 ) {
142+ // not all accounts get this, but some do, not sure why, anyway, if this exist, fb is asking "ey wanna install the fb app instead of using the website?"
143+ // and won't let you proceed further until you say yes or no. so we say no.
144+ $ url = 'https://m.facebook.com ' . $ InstallFacebookAppRequest ->item ( 0 )->getAttribute ( "href " );
145+ $ hc ->exec ( $ url );
146+ $ domd = @\DOMDocument::loadHTML ( $ hc ->getResponseBody () );
147+ }
148+ unset ( $ InstallFacebookAppRequest , $ url , $ xp );
136149 $ logoutUrl = function () use (&$ domd , &$ hc ): string {
137150 foreach ( $ domd ->getElementsByTagName ( "a " ) as $ a ) {
138151 if (strpos ( $ a ->textContent , 'Logout ' ) !== 0 ) {
@@ -152,5 +165,4 @@ function __destruct() {
152165 $ this ->hc ->exec ( $ this ->logoutUrl );
153166 unset ( $ this ->hc ); // im trying to force it to hhb_curl::__destruct, this would be the appropriate time.
154167 }
155-
156168}
0 commit comments