jquery - Pull twitter profile picture without AuthAPI with Javascript - Stack Overflow

admin2025-04-17  0

Is there a way to pull someone's profile picture from Twitter and display it on my site without Auth or Twitter API?

I think it was possible with API v1.1 but support for that has been stopped.

Any suggestions or advice?

Is there a way to pull someone's profile picture from Twitter and display it on my site without Auth or Twitter API?

I think it was possible with API v1.1 but support for that has been stopped.

Any suggestions or advice?

Share Improve this question edited Jan 9, 2014 at 12:51 Daft asked Jan 9, 2014 at 12:46 DaftDaft 11k16 gold badges65 silver badges105 bronze badges 2
  • Since there doesn't appear to be any real meaningful link between the user's screen name and the URL of their profile link, you won't be able do this without OAuth – CodingIntrigue Commented Jan 9, 2014 at 12:49
  • Thanks, I edited my question to remove that suggestion. – Daft Commented Jan 9, 2014 at 12:56
Add a ment  | 

1 Answer 1

Reset to default 7

There's the easy way, or the hard way :-)

The easy way is to use a service like http://avatars.io/

Simply call http://avatars.io/twitter/edent to get my avatar.

The hard way?

You can scrape it directly off the Twitter site. It's not pretty - but it works.

If you look at the source for my Twitter page - https://twitter./edent - you will see this block of HTML.

<a href="/settings/profile"
   class="account-summary account-summary-small"
   data-nav="edit_profile">
  <div class="content">
    <div class="account-group js-mini-current-user" data-user-id="14054507" data-screen-name="edent">
      <img class="avatar size32" src="https://pbs.twimg./profile_images/417381475101593601/UUi48hOg_normal.jpeg" alt="" data-user-id="14054507">
      <b class="fullname">Terence Eden</b>
      <span class="screen-name hidden" dir="ltr">@edent</span>
      <small class="metadata">
          Edit profile

      </small>
    </div>
  </div>
</a>

You can look for the first instance of <img class="avatar size32" and grab the src from that.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1744886101a272544.html

最新回复(0)