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

.NET MAUI Blazor Hybrid (.NET 7) / TweetinviAPI 5.0.4 - Error - Operation is not supported on this platform #1206

Open
seanrco opened this issue Feb 7, 2023 · 0 comments

Comments

@seanrco
Copy link

seanrco commented Feb 7, 2023

I am working on a .NET MAUI Blazor Hybrid (.NET 7) mobile app and using TweetinviAPI 5.0.4. When I test my app locally on my iPhone iOS (16.0.3) it is not working and get the following stack trace error:

[0:] TwitterService.GetTimelineAsync - Error - Operation is not supported on this platform.   at System.Net.Http.NSUrlSessionHandler.set_Proxy(IWebProxy value)
   at System.Net.Http.HttpClientHandler.InvokeNativeHandlerMethod(String name, Object[] parameters)
   at System.Net.Http.HttpClientHandler.SetProxy(IWebProxy value)
   at System.Net.Http.HttpClientHandler.set_Proxy(IWebProxy value)
   at Tweetinvi.WebLogic.TwitterClientHandler.set_TwitterQuery(ITwitterQuery value)
   at Tweetinvi.WebLogic.HttpClientWebHelper.GetHttpClient(ITwitterQuery twitterQuery, ITwitterClientHandler twitterHandler)
   at Tweetinvi.WebLogic.HttpClientWebHelper.GetHttpResponseAsync(ITwitterQuery twitterQuery, ITwitterClientHandler handler)
   at Tweetinvi.WebLogic.WebRequestExecutor.<>c__DisplayClass4_0.<<ExecuteQueryAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Tweetinvi.WebLogic.WebRequestExecutor.<ExecuteTwitterQuerySafelyAsync>d__7`1[[Tweetinvi.Core.Web.ITwitterResponse, Tweetinvi.Core, Version=5.0.4.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Tweetinvi.WebLogic.TwitterRequestHandler.ExecuteQueryAsync(ITwitterRequest request)
   at Tweetinvi.Credentials.TwitterAccessor.<ExecuteRequestAsync>d__4`1[[Tweetinvi.Models.DTO.ITweetDTO[], Tweetinvi.Core, Version=5.0.4.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Tweetinvi.Core.Iterators.TwitterPageIterator`2.<NextPageAsync>d__12[[Tweetinvi.Core.Web.ITwitterResult`1[[Tweetinvi.Models.DTO.ITweetDTO[], Tweetinvi.Core, Version=5.0.4.0, Culture=neutral, PublicKeyToken=null]], Tweetinvi.Core, Version=5.0.4.0, Culture=neutral, PublicKeyToken=null],[System.Nullable`1[[System.Int64, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at Tweetinvi.Core.Iterators.TwitterIteratorProxy`3.<NextPageAsync>d__12[[Tweetinvi.Core.Web.ITwitterResult`1[[Tweetinvi.Models.DTO.ITweetDTO[], Tweetinvi.Core, Version=5.0.4.0, Culture=neutral, PublicKeyToken=null]], Tweetinvi.Core, Version=5.0.4.0, Culture=neutral, PublicKeyToken=null],[Tweetinvi.Models.ITweet, Tweetinvi.Core, Version=5.0.4.0, Culture=neutral, PublicKeyToken=null],[System.Nullable`1[[System.Int64, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at Tweetinvi.Client.TimelinesClient.GetUserTimelineAsync(IGetUserTimelineParameters parameters)

My Service code example that is called when error occurs:

using System.Diagnostics;
using Tweetinvi;
using Tweetinvi.Models;

namespace FooMobileApp.Services;

public class TwitterService
{

    private readonly string TWITTER_API_KEY = "######";
    private readonly string TWITTER_API_SECRET = "######";
    private readonly string TWITTER_API_TOKEN = "######";
    private readonly string TIMELINE_USER = "foo"; // note this is made up for code example

    TwitterClient twitterClient;
	
    public TwitterService()
    {
        this.twitterClient = new TwitterClient(TWITTER_API_KEY, TWITTER_API_SECRET, TWITTER_API_TOKEN);
    }

    public async Task<ITweet[]> GetTimelineAsync(int numTweets = 25)
    {
        ITweet[] tweets = null;

        try
        {
            tweets = await twitterClient.Timelines.GetUserTimelineAsync(TIMELINE_USER);

            if (tweets != null && tweets.Length > 0)
            {
                tweets = tweets.Take(numTweets).ToArray();
            }
        }
        catch (Exception ex)
        {
            Debug.WriteLine("TwitterService.GetTimelineAsync - Error - " + ex.Message + ex.StackTrace);
        }

        return tweets;
    }

}

Any suggestions?

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

2 participants
@seanrco and others