问题
Based upon this answer here: Building Twitter profile image url with Twitter user id
I implemented some functionality for a client's website that showed a Twitter profile picture's img so it could be displayed on our site. ( https://twitter.com/[screen_name]/profile_image?size=original )
Unfortunately after coming back to the project after a couple weeks it looks like Twitter has now blocked this functionality. Looking at the response headers I see:
After poking around a bit it looks like the content-security-policy
and perhaps also the x-frame-options
settings are preventing the functionality from working now. Am I correct in my assumption and are there any workarounds (other than using the API to get the profile image url via this API: https://developer.twitter.com/en/docs/accounts-and-users/user-profile-images-and-banners )
回答1:
The API is the correct way to obtain these URLs and images. The way you were doing it was never a documented or supported manner of getting profile images. There’s no workaround for your current method, you should use the official API.
来源:https://stackoverflow.com/questions/60330354/twitter-profile-picture-images-now-blocked-on-most-domains