@@ -327,15 +327,15 @@ function mathilda_import_file( $file ) {
327327 $ hashtag_index_e =false ;
328328 $ hashtags_yes_or_no ="FALSE " ;
329329
330- if (array_key_exists ('0 ' , $ items ['entities ' ]['hashtags ' ]))
330+ if (array_key_exists ('0 ' , $ items ['tweet ' ][ ' entities ' ]['hashtags ' ]))
331331 {
332- foreach ($ items ['entities ' ]['hashtags ' ] as $ hashtags )
332+ foreach ($ items ['tweet ' ][ ' entities ' ]['hashtags ' ] as $ hashtags )
333333 {
334334 $ hashtag_text =$ hashtags ['text ' ];
335335 $ hashtag_index_s =$ hashtags ['indices ' ][0 ];
336336 $ hashtag_index_e =$ hashtags ['indices ' ][1 ];
337337 $ hashtags_yes_or_no ="TRUE " ;
338- $ hashtag_cache []=array ($ hashtag_text ,$ hashtag_index_s ,$ hashtag_index_e ,$ items ['id_str ' ]);
338+ $ hashtag_cache []=array ($ hashtag_text ,$ hashtag_index_s ,$ hashtag_index_e ,$ items ['tweet ' ][ ' id_str ' ]);
339339 $ num_hashtags =$ num_hashtags +1 ;
340340 }
341341 }
@@ -349,17 +349,17 @@ function mathilda_import_file( $file ) {
349349 $ mention_index_end =false ;
350350 $ mentions_yes_or_no ="FALSE " ;
351351
352- if (array_key_exists ('0 ' , $ items ['entities ' ]['user_mentions ' ]))
352+ if (array_key_exists ('0 ' , $ items ['tweet ' ][ ' entities ' ]['user_mentions ' ]))
353353 {
354- foreach ($ items ['entities ' ]['user_mentions ' ] as $ mentions )
354+ foreach ($ items ['tweet ' ][ ' entities ' ]['user_mentions ' ] as $ mentions )
355355 {
356356 $ mention_useridstr =$ mentions ['id_str ' ];
357357 $ mention_screenname =$ mentions ['screen_name ' ];
358358 $ mention_fullname =$ mentions ['name ' ];
359359 $ mention_index_start =$ mentions ['indices ' ][0 ];
360360 $ mention_index_end =$ mentions ['indices ' ][1 ];
361361 $ mentions_yes_or_no ="TRUE " ;
362- $ mention_cache []=array ($ mention_useridstr ,$ mention_screenname ,$ mention_fullname ,$ mention_index_start ,$ mention_index_end ,$ items ['id_str ' ]);
362+ $ mention_cache []=array ($ mention_useridstr ,$ mention_screenname ,$ mention_fullname ,$ mention_index_start ,$ mention_index_end ,$ items ['tweet ' ][ ' id_str ' ]);
363363 $ num_mentions =$ num_mentions +1 ;
364364 }
365365 }
@@ -373,17 +373,17 @@ function mathilda_import_file( $file ) {
373373 $ url_index_end =false ;
374374 $ urls_yes_or_no ="FALSE " ;
375375
376- if (array_key_exists ('0 ' , $ items ['entities ' ]['urls ' ]))
376+ if (array_key_exists ('0 ' , $ items ['tweet ' ][ ' entities ' ]['urls ' ]))
377377 {
378- foreach ($ items ['entities ' ]['urls ' ] as $ urls )
378+ foreach ($ items ['tweet ' ][ ' entities ' ]['urls ' ] as $ urls )
379379 {
380380 $ url_tco =$ urls ['url ' ];
381381 $ url_extended =$ urls ['expanded_url ' ];
382382 $ url_display =$ urls ['display_url ' ];
383383 $ url_index_start =$ urls ['indices ' ][0 ];
384384 $ url_index_end =$ urls ['indices ' ][1 ];
385385 $ urls_yes_or_no ="TRUE " ;
386- $ url_cache []=array ($ url_tco ,$ url_extended ,$ url_display ,$ url_index_start ,$ url_index_end ,$ items ['id_str ' ]);
386+ $ url_cache []=array ($ url_tco ,$ url_extended ,$ url_display ,$ url_index_start ,$ url_index_end ,$ items ['tweet ' ][ ' id_str ' ]);
387387 $ num_urls =$ num_urls +1 ;
388388 }
389389 }
@@ -404,9 +404,9 @@ function mathilda_import_file( $file ) {
404404 $ index_end =false ;
405405 $ media_yes_or_no ="FALSE " ;
406406
407- if (isset ($ items ['entities ' ]['media ' ]))
407+ if (isset ($ items ['tweet ' ][ ' entities ' ]['media ' ]))
408408 {
409- foreach ($ items ['entities ' ]['media ' ] as $ images )
409+ foreach ($ items ['tweet ' ][ ' entities ' ]['media ' ] as $ images )
410410 {
411411
412412 $ media_idstr =$ images ['id_str ' ];
@@ -416,23 +416,9 @@ function mathilda_import_file( $file ) {
416416 $ media_displayurl =$ images ['display_url ' ];
417417 $ media_extendedurl =$ images ['expanded_url ' ];
418418
419- /*
420- Twitter Export JSON does not contain the size-array (small, medium, large, xxx)
421- Search Largest Value Pair
422- */
423-
424- $ select_size =0 ;
425- for ($ x =0 ; $ x <4 ; $ x ++)
426- {
427- if ($ images ['sizes ' ][$ select_size ]['w ' ]<$ images ['sizes ' ][($ x +1 )]['w ' ])
428- {
429- $ select_size =($ x +1 );
430- }
431- }
432-
433- $ media_size_w =$ images ['sizes ' ][$ select_size ]['w ' ];
434- $ media_size_h =$ images ['sizes ' ][$ select_size ]['h ' ];
435- $ media_size_resize =$ images ['sizes ' ][$ select_size ]['resize ' ];
419+ $ media_size_w =$ images ['sizes ' ]['large ' ]['w ' ];
420+ $ media_size_h =$ images ['sizes ' ]['large ' ]['h ' ];
421+ $ media_size_resize =$ images ['sizes ' ]['large ' ]['resize ' ];
436422 $ media_type ='photo ' ;
437423 $ index_start =$ images ['indices ' ][0 ];
438424 $ index_end =$ images ['indices ' ][1 ];
@@ -457,7 +443,7 @@ function mathilda_import_file( $file ) {
457443
458444 // Update Media Array
459445
460- $ media_cache []=array ($ media_idstr ,$ media_mediaurl ,$ media_mediaurlhttps ,$ media_url ,$ media_displayurl ,$ media_extendedurl , $ media_size_w , $ media_size_h , $ media_size_resize ,$ media_type , $ index_start , $ index_end ,$ items ['id_str ' ],$ filename ,$ loaded );
446+ $ media_cache []=array ($ media_idstr ,$ media_mediaurl ,$ media_mediaurlhttps ,$ media_url ,$ media_displayurl ,$ media_extendedurl , $ media_size_w , $ media_size_h , $ media_size_resize ,$ media_type , $ index_start , $ index_end ,$ items ['tweet ' ][ ' id_str ' ],$ filename ,$ loaded );
461447 $ media_yes_or_no ="TRUE " ;
462448 $ num_media =$ num_media +1 ;
463449 }
@@ -470,16 +456,19 @@ function mathilda_import_file( $file ) {
470456 $ tweet_retweet ="FALSE " ;
471457 $ tweet_quote ="FALSE " ;
472458
473- if (isset ($ items ['retweeted_status ' ])) {
474- $ tweet_retweet ="TRUE " ;
459+ // Identify Retweets
460+ $ is_retweet = strpos ($ items ['tweet ' ]['full_text ' ], 'RT ' );
461+ if ($ is_retweet ===0 ) {
462+ $ tweet_retweet ="TRUE " ;
475463 }
476- if (isset ($ items ['truncated ' ])) {
477- if ($ items ['truncated ' ]=='true ' ) {
464+
465+ if (isset ($ items ['tweet ' ]['truncated ' ])) {
466+ if ($ items ['tweet ' ]['truncated ' ]=='true ' ) {
478467 $ tweet_truncate ="TRUE " ;
479468 }
480469 }
481- if (isset ($ items ['in_reply_to_status_id ' ])) {
482- if ($ items ['in_reply_to_status_id ' ]!=null ) {
470+ if (isset ($ items ['tweet ' ][ ' in_reply_to_user_id ' ])) {
471+ if ($ items ['tweet ' ][ ' in_reply_to_user_id ' ]!=null ) {
483472 $ tweet_reply ="TRUE " ;
484473 }
485474 }
@@ -490,9 +479,9 @@ function mathilda_import_file( $file ) {
490479 }
491480
492481 $ tweet_cache []=array ($ num_tweets ,
493- $ items ['id_str ' ],
494- $ items ['text ' ],
495- $ items ['created_at ' ],
482+ $ items ['tweet ' ][ ' id_str ' ],
483+ $ items ['tweet ' ][ ' full_text ' ],
484+ $ items ['tweet ' ][ ' created_at ' ],
496485 $ hashtags_yes_or_no ,
497486 $ mentions_yes_or_no ,
498487 $ media_yes_or_no ,
@@ -518,10 +507,8 @@ function mathilda_import_file( $file ) {
518507
519508 // Convert Date
520509
521- $ tweet_cache [$ i ][3 ]=str_replace ( '- ' , '' , $ tweet_cache [$ i ][3 ] );
522- $ tweet_cache [$ i ][3 ]=str_replace ( ' ' , '' , $ tweet_cache [$ i ][3 ] );
523- $ tweet_cache [$ i ][3 ]=str_replace ( ': ' , '' , $ tweet_cache [$ i ][3 ] );
524- $ tweet_cache [$ i ][3 ]=str_replace ( '+0000 ' , '' , $ tweet_cache [$ i ][3 ] );
510+ $ tweet_date =strtotime ($ tweet_cache [$ i ][3 ]);
511+ $ tweet_cache [$ i ][3 ]=date ('YmdHis ' , $ tweet_date );
525512
526513 // Update Tweets
527514
0 commit comments