Andrea
Andrea

Reputation: 79

download twitter image with php

Dear I'm trying to download images associated to tweets but I have a lot of problem.

Firstly I found that entities->media[0]->media_url contains the image Url but it is not the same in every tweet.

Now I see a tweet with associated urls for photo on YFROG.com be in entities->urls

I can't find the right documentation or example code: can you please help me? thanks A

Upvotes: 0

Views: 1375

Answers (1)

Kiran Ruth R
Kiran Ruth R

Reputation: 1012

You can get the media entities as explained in this doc https://dev.twitter.com/docs/tweet-entities

to get the image , u can use file_get_contents($image)

so ur code would something look like

<?php
   $value = file_get_contents($image);
   $fp = fopen('path_to_filename.png', 'w');
   fwrite($fp, $value); 
   fclose($fp); 

?>

Hope this helps

Upvotes: 1

Related Questions