Пример #1
0
        async Task <bool> SubmitScrobbleToTwitter(Song song)
        {
            try
            {
                                #if __IOS__
                var store = new ACAccountStore();
                //var accountType = store.FindAccountType(ACAccountType.Twitter);
                var account = store.FindAccount(Settings.TwitterAccount);

                var message = $"#NowPlaying {song.ToString(114)} on @gMusicApp";

                var request = new TWRequest(new NSUrl("https://api.twitter.com/1.1/statuses/update.json"), NSDictionary.FromObjectAndKey((NSString)message, (NSString)"status"), TWRequestMethod.Post);
                request.Account = account;
                var result = await request.PerformRequestAsync();
                                #endif
                return(true);
            }
            catch (Exception ex)
            {
                LogManager.Shared.Report(ex);
                return(false);
            }
        }
Пример #2
0
        async Task <bool> SubmitScrobbleToTwitter(Song song)
        {
            var message = $"#NowPlaying {song.ToString(254)} on @gMusicApp";

            try
            {
                if (!Device.HasIntegratedTwitter)
                {
                    var resp = await twitter.Post(null, "statuses/update.json", new Dictionary <string, string>
                    {
                        ["status"] = message
                    });

                    Console.WriteLine(resp);
                }
                else
                {
#if __IOS__
                    var store = new ACAccountStore();
                    //var accountType = store.FindAccountType(ACAccountType.Twitter);
                    var account = store.FindAccount(Settings.TwitterAccount);


                    var request = new TWRequest(new NSUrl("https://api.twitter.com/1.1/statuses/update.json"), NSDictionary.FromObjectAndKey((NSString)message, (NSString)"status"), TWRequestMethod.Post);
                    request.Account = account;
                    var result = await request.PerformRequestAsync();
#endif
                }
                return(true);
            }
            catch (Exception ex)
            {
                LogManager.Shared.Report(ex);
                return(false);
            }
        }