MarikIshtar007 / facebook_posts

A flutter package to query data about facebook posts.
MIT License
1 stars 0 forks source link

XMLHttpRequest error. #2

Open jeansebastienZ opened 3 years ago

jeansebastienZ commented 3 years ago

Hello ,

I'm unable to use your package due to an Error: XMLHttpRequest error.

My flutter channel : Flutter (Channel master, 1.26.0-2.0.pre.335

Complete error :

Error: XMLHttpRequest error.
    dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 906:28                get current
packages/http/src/browser_client.dart 84:22                                       <fn>
dart-sdk/lib/async/zone.dart 1446:54                                              runUnary
dart-sdk/lib/async/future_impl.dart 150:18                                        handleValue
dart-sdk/lib/async/future_impl.dart 708:44                                        handleValueCallback
dart-sdk/lib/async/future_impl.dart 737:13                                        _propagateToListeners
dart-sdk/lib/async/future_impl.dart 532:7                                         [_complete]
dart-sdk/lib/async/stream_pipe.dart 61:11                                         _cancelAndValue
dart-sdk/lib/async/stream.dart 1302:7                                             <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 324:14  _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 329:39  dcall
dart-sdk/lib/html/dart2js/html_dart2js.dart 37307:58                              <fn>
MarikIshtar007 commented 3 years ago

Hi, can you provide an example code to recreate the issue?

jeansebastienZ commented 3 years ago

Hello :

Here one widget for the example , as its the basic example you gave , i did not initially send the code , but here we go :

class footer extends StatefulWidget {
  @override
  _footerState createState() => _footerState();
}

class _footerState extends State<footer> {
  FacebookPost fbp = FacebookPost();
  var myPost = [];

  void getFbPosts() async {
    myPost = await fbp.getFbData('https://www.facebook.com/symeg971/posts');
  }

  Widget myWidget = Container();

  @override
  Widget build(BuildContext context) {
    return
              Container(
                height: 1000,
                width:1000,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Container(
                      height: MediaQuery.of(context).size.height * 0.4,
                      child: Center(
                        child: RaisedButton(
                          child: Text('Press to get Post Data'),
                          onPressed: () async {
                            await getFbPosts();
                            setState(() {
                              myWidget = myList(myPost);
                            });
                          },
                        ),
                      ),
                    ),
                    Expanded(flex: 1, child: myWidget)
                  ],
                ),
              );

  }
}

Widget myList(var theList) {
  print("frfrfrf" +theList.toString());
  return ListView.separated(
      separatorBuilder: (context, index) => Divider(
        thickness: 1,
      ),
      shrinkWrap: true,
      itemCount: theList.length,
      itemBuilder: (context, index) {
        print(theList[index].imagesUrl);
        var data = theList[index];
        return Padding(
            padding: const EdgeInsets.all(8.0),
            child: Container(
              color: Color(0xFFF0F0F0),
              child: ListTile(
                title: Text(data.title),
                subtitle: SizedBox(
                  height: 120,
                  width: 300,
                  child: ListView.separated(
                    separatorBuilder: (context, index) => VerticalDivider(
                      thickness: 1,
                    ),
                    scrollDirection: Axis.horizontal,
                    shrinkWrap: true,
                    itemCount: data.imagesUrl.length,
                    itemBuilder: (context, index) =>
                        Image.network(data.imagesUrl[index]),
                  ),
                ),
              ),
            ));
      });
}
MarikIshtar007 commented 3 years ago

Hey. I checked it out. Unfortunately, I could not recreate the issue. It worked fine for me. Without any errors. Is it possible that you are using this in flutter web and not on flutter android? If so, please note that the package is not yet ready for Flutter web version. You can follow this and this link to try and resolve that problem for web.

jeansebastienZ commented 3 years ago

Hello , indeed i'm using flutter web but your package is listed as ready for WEB : https://i.ibb.co/tYdWGdS/Capture-d-e-cran-2021-02-25-a-17-42-09.png .

Already looked at those solution , without any success . Thank you anyway .

Mobiwoom commented 3 years ago

same issue !

MarikIshtar007 commented 3 years ago

I'll be upgrading the package to better suit Flutter 2 as well as rewriting the code with a proper web scraping tool. Please hold on for 2 weeks as I have my exams going on.

Edit : I have been running into trouble as the few methods that I have been working on, have been shutdown by facebook on account of being 'not the right way' and I also ended up getting my account banned. Looks Like facebook has tightened its security and makes sure scraping is difficult to achieve. I will be thus discontinuing this package until further notice.