Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

searchTweets returns a null error #12

Open
neovea opened this issue Dec 12, 2016 · 1 comment
Open

searchTweets returns a null error #12

neovea opened this issue Dec 12, 2016 · 1 comment

Comments

@neovea
Copy link

neovea commented Dec 12, 2016

Hello,

I'm trying to make a search query to Twitter Rest API. Whereas getting data via getHomeTimeline() works, getting some via searchTweets() doesn't.

angular.module('app')
    .controller('TwitterCtrl', function($scope, $ionicPlatform, $twitterApi, $cordovaOauth){

        var twitterKey = 'STORAGE.TWITTER.KEY';
        var clientId = 'clientidkey';
        var clientSecret = 'clientsecretkey';
        var myToken = '';

        $scope.tweets = {};

        $ionicPlatform.ready(function() {
            myToken = JSON.parse(window.localStorage.getItem(twitterKey));
            if (myToken === '' || myToken === null) {
                $cordovaOauth.twitter(clientId, clientSecret).then(function (succ) {
                    myToken = succ;
                    window.localStorage.setItem(twitterKey, JSON.stringify(succ));
                    $twitterApi.configure(clientId, clientSecret, succ);
                }, function(error) {
                    console.log("FAILED because of : " + error);
                });
            } else {
                $twitterApi.configure(clientId, clientSecret, myToken);
            }
        });

        $scope.searchTweets = function() {
            $twitterApi.searchTweets("ionic").then(function(result){
                $scope.tweets = result;
            }, function(result){
                console.log("search tweets error because of : "+result);
            });
        };
    })

This doesn't work :

            $twitterApi.searchTweets("ionic").then(function(result){
                $scope.tweets = result;
            }, function(result){
                console.log("search tweets error because of : "+result);
            });

this works :

            $twitterApi.getHomeTimeline().then(function(result) {
                $scope.tweets = result;
            }, function(result){
                console.log("show home timeline error : "+result);
            });

I'm using ng-cordova-oauth, ionic 2.1.13,
I'm running it in emulator.
The errors in my console client log are :

0     956097   warn     Google Maps API warning: SensorNotRequired https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required
1     212825   log      FAILED because of : null
2     212855   log      FAILED because of : null

Did I miss something ?

Thank you for helping out :)

@neovea
Copy link
Author

neovea commented Dec 13, 2016

Alright, this is odd : it works when I build and run the ionic app. Emulating it doesn't seem to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant