php - How to only save new tweets/instagram photos to database? -
i'm building 2 cron-jobs regularly searches new tweets , instagram photos(and potentially more services) based on tag.
the content saved database , later outputted webpage. allows faster loading , more importantly ability remove tweets not displayed.
i want make sure no posts saved twice in database , not sure approach best. here options consider:
- i use laravel , has ability demand postid unique, make database refuse when try save existing posts. might render unnesseary sql-queries though.
- i check database latest saved post id , stop loop once post.
- atleast in twitter, can pass parameter since_id, wich allows me latest posts. haven't found same parameter in instagram , wouldn't work html-scraping either.
twitter provides 'created_at' value, giving date , time tweet created.
each time cron job runs, store date , time, on next run, upload tweet if date/time prior value of 'created_at'.
i'm not familiar instagram, sorry - assume same logic apply.
["created_at":"wed aug 27 13:08:45 +0000 2008"][1]
Comments
Post a Comment