99use App \TwitterUnfollower ;
1010use Carbon \Carbon ;
1111use Illuminate \Console \Command ;
12+ use Exception ;
1213
13- class Twitter_CheckUnfollows extends Command
14- {
14+ class Twitter_CheckUnfollows extends Command {
1515 /**
1616 * The name and signature of the console command.
1717 *
@@ -31,8 +31,7 @@ class Twitter_CheckUnfollows extends Command
3131 *
3232 * @return void
3333 */
34- public function __construct ()
35- {
34+ public function __construct () {
3635 parent ::__construct ();
3736 }
3837
@@ -41,33 +40,32 @@ public function __construct()
4140 *
4241 * @return mixed
4342 */
44- public function handle ()
45- {
43+ public function handle () {
4644
47- if (!config ('app.twitter.crawling ' )) {
45+ if (!config ('app.twitter.crawling ' )) {
4846 dump ("Twitter crawling currently deactivated. " );
4947 return ;
5048 }
5149
5250 $ toCheck = TwitterFollower::orderBy ('updated_at ' , 'asc ' )->limit ($ this ->argument ('limit ' ))->get ();
53- foreach ($ toCheck as $ relationship ) {
51+ foreach ($ toCheck as $ relationship ) {
5452 try {
5553 $ sl_profile = SocialLoginProfile::where ('twitter_id ' , $ relationship ->followed_id )->where ('twitter_token ' , '<> ' , null )->first ();
56- if ($ sl_profile == null ) {
54+ if ($ sl_profile == null ) {
5755 dump ("No SL Profile " . $ relationship ->followed ->screen_name );
5856 continue ;
5957 }
6058
6159 $ connection = TwitterApiController::getNewConnection ($ sl_profile );
62- if (!TwitterApiController::canRequest ($ sl_profile , 'users/show ' , 900 )) {
60+ if (!TwitterApiController::canRequest ($ sl_profile , 'users/show ' , 900 )) {
6361 dump ("No Requests " . $ sl_profile ->twitter_id );
6462 continue ;
6563 }
6664
6765 $ follower = $ connection ->get ('users/show ' , ['user_id ' => $ relationship ->follower_id ]);
68- if (isset ($ follower ->errors )) {
69- foreach ($ follower ->errors as $ error ) {
70- if ($ error ->code == 50 || $ error ->code == 63 ) { //not found, suspendet
66+ if (isset ($ follower ->errors )) {
67+ foreach ($ follower ->errors as $ error ) {
68+ if ($ error ->code == 50 || $ error ->code == 63 ) { //not found, suspendet
7169 dump ("User not found -> handle Unfollow " );
7270 $ relationship ->delete ();
7371
@@ -83,16 +81,16 @@ public function handle()
8381 }
8482 }
8583
86- if (!TwitterApiController::canRequest ($ sl_profile , 'friendships/lookup ' , 15 )) {
84+ if (!TwitterApiController::canRequest ($ sl_profile , 'friendships/lookup ' , 15 )) {
8785 dump ("No Requests " . $ sl_profile ->twitter_id );
8886 continue ;
8987 }
9088
9189 $ result = $ connection ->get ("friendships/lookup " , ['user_id ' => $ relationship ->follower_id ]); //TODO: multiple requests
9290 TwitterApiController::saveRequest ($ sl_profile , 'friendships/lookup ' );
9391
94- foreach ($ result as $ real_relationship ) {
95- if (!isset ($ real_relationship ->connections )) {
92+ foreach ($ result as $ real_relationship ) {
93+ if (!isset ($ real_relationship ->connections )) {
9694 dump ($ real_relationship );
9795 dump ("No Connection array? " );
9896 continue ;
@@ -101,7 +99,7 @@ public function handle()
10199 //$following = in_array('following', $real_relationship->connections);
102100 $ followed_by = in_array ('followed_by ' , $ real_relationship ->connections );
103101
104- if (!$ followed_by ) {
102+ if (!$ followed_by ) {
105103 dump ("User " . $ relationship ->follower ->screen_name . ' hat ' . $ relationship ->followed ->screen_name . ' entfolgt. ' );
106104 $ relationship ->delete ();
107105
@@ -118,7 +116,7 @@ public function handle()
118116 $ relationship ->update ();
119117 }
120118 }
121- } catch ( \ Exception $ e ) {
119+ } catch ( Exception $ e ) {
122120 dump ($ e );
123121 report ($ e );
124122 }
0 commit comments