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

No preview is loaded for a link to a tweet on Twitter #134

Open
smaljaar opened this issue Feb 10, 2021 · 5 comments
Open

No preview is loaded for a link to a tweet on Twitter #134

smaljaar opened this issue Feb 10, 2021 · 5 comments
Labels
good first issue This issue is good for beginners to start contributing. investigation-needed

Comments

@smaljaar
Copy link

Using:
SwiftLinkPreview 3.3.0
Xcode 12.4

Example:
If you provide https://twitter.com/joshdholtz/status/1359219485543182337?s=20 as text to SwiftLinkPreview's preview(text:onSuccess:onFailure) method it responds in the success block with

Response(url: Optional(https://twitter.com/joshdholtz/status/1359219485543182337?s=20), finalUrl: Optional(https://twitter.com/joshdholtz/status/1359219485543182337?s=20), canonicalUrl: Optional("twitter.com"), title: nil, description: Optional("We’ve detected that JavaScript is disabled in this browser. Please enable JavaScript or switch to a supported browser to continue using twitter.com. You can see a list of supported browsers in our Help Center."), images: Optional(["https://abs.twimg.com/errors/logo46x38.png"]), image: Optional("https://abs.twimg.com/errors/logo46x38.png"), icon: Optional("https://abs.twimg.com/responsive-web/client-web-legacy/icon-ios.b1fc7275.png"), video: nil, price: nil)

The title is nil, and the images are generic Twitter icons not related to the Tweet.

@LeonardoCardoso LeonardoCardoso added good first issue This issue is good for beginners to start contributing. investigation-needed labels Feb 10, 2021
@kodekarim
Copy link

Tested with some random Twitter link, the same error message of javascript is coming

@chrysb
Copy link

chrysb commented Jul 19, 2021

Anyone have a workaround for this? Would love to be able to embed tweets

@chrysb
Copy link

chrysb commented Jul 19, 2021

I actually figured a workaround using nitter.net (this site mirrors twitter.com and is non-javascript friendly). If I detect twitter.com, I swap out the domain to nitter.com for the unfurling, and then I switch it back before sending the data along:

if url.contains("/status/") && url.contains("twitter.com") {
  url = String(url).replacingOccurrences(of: "twitter.com", with: "nitter.net")
}

@chadpav
Copy link

chadpav commented Nov 13, 2021

Just tested the twitter link using the patch I submitted in #155 and it works.

Looks like the user agent might be the root issue of multiple issues.

@Razanajam
Copy link

Razanajam commented Mar 26, 2022

@LeonardoCardoso Can you please check this issue, I believe you have done an amazing job on this module. Can you please fix some of the issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This issue is good for beginners to start contributing. investigation-needed
Projects
None yet
Development

No branches or pull requests

6 participants