@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | $servicename = $bigcartel->serviceName; |
23 | 23 | |
24 | 24 | // step 2: redirect to the provider's login screen |
25 | -if(isset($_GET['login']) && $_GET['login'] === $servicename){ |
|
25 | +if (isset($_GET['login']) && $_GET['login'] === $servicename) { |
|
26 | 26 | header('Location: '.$bigcartel->getAuthURL(null, $scopes)); |
27 | 27 | } |
28 | 28 | // step 3: receive the access token |
29 | -elseif(isset($_GET['code']) && isset($_GET['state'])){ |
|
29 | +elseif (isset($_GET['code']) && isset($_GET['state'])) { |
|
30 | 30 | $token = $bigcartel->getAccessToken($_GET['code'], $_GET['state']); |
31 | 31 | |
32 | 32 | $account_id = $token->extraParams['account_id']; |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | header('Location: ?granted='.$servicename); |
38 | 38 | } |
39 | 39 | // step 4: verify the token and use the API |
40 | -elseif(isset($_GET['granted']) && $_GET['granted'] === $servicename){ |
|
40 | +elseif (isset($_GET['granted']) && $_GET['granted'] === $servicename) { |
|
41 | 41 | echo '<pre>'.print_r(Psr7\get_json($bigcartel->account()), true).'</pre>'; |
42 | 42 | } |
43 | 43 | // step 1 (optional): display a login link |
44 | -else{ |
|
44 | +else { |
|
45 | 45 | echo '<a href="?login='.$servicename.'">connect with '.$servicename.'!</a>'; |
46 | 46 | } |
47 | 47 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | ]; |
29 | 29 | |
30 | 30 | // step 2: redirect to the provider's login screen |
31 | -if(isset($_GET['login']) && $_GET['login'] === $musicbrainz->serviceName){ |
|
31 | +if (isset($_GET['login']) && $_GET['login'] === $musicbrainz->serviceName) { |
|
32 | 32 | |
33 | 33 | $params = [ |
34 | 34 | 'access_type' => 'offline', |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | header('Location: '.$musicbrainz->getAuthURL($params, $scopes)); |
40 | 40 | } |
41 | 41 | // step 3: receive the access token |
42 | -elseif(isset($_GET['code']) && isset($_GET['state'])){ |
|
42 | +elseif (isset($_GET['code']) && isset($_GET['state'])) { |
|
43 | 43 | $token = $musicbrainz->getAccessToken($_GET['code'], $_GET['state']); |
44 | 44 | |
45 | 45 | // save the token [...] |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | header('Location: ?granted='.$musicbrainz->serviceName); |
49 | 49 | } |
50 | 50 | // step 4: verify the token and use the API |
51 | -elseif(isset($_GET['granted']) && $_GET['granted'] === $musicbrainz->serviceName){ |
|
51 | +elseif (isset($_GET['granted']) && $_GET['granted'] === $musicbrainz->serviceName) { |
|
52 | 52 | echo '<pre>'.print_r(Psr7\get_json($musicbrainz->artistId('573510d6-bb5d-4d07-b0aa-ea6afe39e28d', ['inc' => 'url-rels work-rels'])), true).'</pre>'; |
53 | 53 | } |
54 | 54 | // step 1 (optional): display a login link |
55 | -else{ |
|
55 | +else { |
|
56 | 56 | echo '<a href="?login='.$musicbrainz->serviceName.'">connect with '.$musicbrainz->serviceName.'!</a>'; |
57 | 57 | } |
58 | 58 |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | $servicename = $mailchimp->serviceName; |
24 | 24 | |
25 | 25 | // step 2: redirect to the provider's login screen |
26 | -if(isset($_GET['login']) && $_GET['login'] === $servicename){ |
|
26 | +if (isset($_GET['login']) && $_GET['login'] === $servicename) { |
|
27 | 27 | header('Location: '.$mailchimp->getAuthURL(null, $scopes)); |
28 | 28 | } |
29 | 29 | // step 3: receive the access token |
30 | -elseif(isset($_GET['code']) && isset($_GET['state'])){ |
|
30 | +elseif (isset($_GET['code']) && isset($_GET['state'])) { |
|
31 | 31 | $token = $mailchimp->getAccessToken($_GET['code'], $_GET['state']); |
32 | 32 | |
33 | 33 | // MailChimp needs another call to the auth metadata endpoint |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | header('Location: ?granted='.$servicename); |
42 | 42 | } |
43 | 43 | // step 4: verify the token and use the API |
44 | -elseif(isset($_GET['granted']) && $_GET['granted'] === $servicename){ |
|
44 | +elseif (isset($_GET['granted']) && $_GET['granted'] === $servicename) { |
|
45 | 45 | echo '<pre>'.print_r(Psr7\get_json($mailchimp->root()), true).'</pre>'; |
46 | 46 | } |
47 | 47 | // step 1 (optional): display a login link |
48 | -else{ |
|
48 | +else { |
|
49 | 49 | echo '<a href="?login='.$servicename.'">connect with '.$servicename.'!</a>'; |
50 | 50 | } |
51 | 51 |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | $servicename = $spotify->serviceName; |
44 | 44 | |
45 | 45 | // step 2: redirect to the provider's login screen |
46 | -if(isset($_GET['login']) && $_GET['login'] === $servicename){ |
|
46 | +if (isset($_GET['login']) && $_GET['login'] === $servicename) { |
|
47 | 47 | header('Location: '.$spotify->getAuthURL(null, $scopes)); |
48 | 48 | } |
49 | 49 | // step 3: receive the access token |
50 | -elseif(isset($_GET['code']) && isset($_GET['state'])){ |
|
50 | +elseif (isset($_GET['code']) && isset($_GET['state'])) { |
|
51 | 51 | $token = $spotify->getAccessToken($_GET['code'], $_GET['state']); |
52 | 52 | |
53 | 53 | // save the token [...] |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | header('Location: ?granted='.$servicename); |
57 | 57 | } |
58 | 58 | // step 4: verify the token and use the API |
59 | -elseif(isset($_GET['granted']) && $_GET['granted'] === $servicename){ |
|
59 | +elseif (isset($_GET['granted']) && $_GET['granted'] === $servicename) { |
|
60 | 60 | echo '<pre>'.print_r(Psr7\get_json($spotify->me()), true).'</pre>'; |
61 | 61 | } |
62 | 62 | // step 1 (optional): display a login link |
63 | -else{ |
|
63 | +else { |
|
64 | 64 | echo '<a href="?login='.$servicename.'">connect with '.$servicename.'!</a>'; |
65 | 65 | } |
66 | 66 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $after = null; |
42 | 42 | |
43 | 43 | // fetch the artists you're following |
44 | -while(true){ |
|
44 | +while (true) { |
|
45 | 45 | |
46 | 46 | $meFollowing = $spotify->meFollowing([ |
47 | 47 | 'type' => 'artist', |
@@ -51,21 +51,21 @@ discard block |
||
51 | 51 | |
52 | 52 | $data = Psr7\get_json($meFollowing); |
53 | 53 | |
54 | - if($meFollowing->getStatusCode() === 200){ |
|
54 | + if ($meFollowing->getStatusCode() === 200) { |
|
55 | 55 | |
56 | - foreach($data->artists->items as $artist){ |
|
56 | + foreach ($data->artists->items as $artist) { |
|
57 | 57 | $logger->info('+ '.$artist->name); |
58 | 58 | $artists[] = $artist->id; |
59 | 59 | } |
60 | 60 | |
61 | 61 | $after = $data->artists->cursors->after ?? null; |
62 | 62 | |
63 | - if(empty($after)){ |
|
63 | + if (empty($after)) { |
|
64 | 64 | break; |
65 | 65 | } |
66 | 66 | |
67 | 67 | } |
68 | - elseif(isset($data->error)){ |
|
68 | + elseif (isset($data->error)) { |
|
69 | 69 | $logger->error($data->error->message.' ('.$data->error->status.')'); |
70 | 70 | # throw new \Exception($data->error->message, $data->error->status); |
71 | 71 | } |
@@ -74,17 +74,17 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | // now crawl the artists' new releases |
77 | -foreach($artists as $id){ |
|
77 | +foreach ($artists as $id) { |
|
78 | 78 | // WTB bulk endpoint /artists/albums?ids=artist_id1,artist_id2,... |
79 | 79 | $artistAlbums = Psr7\get_json($spotify->artistAlbums($id, ['market' => $market])); |
80 | 80 | |
81 | - foreach($artistAlbums->items ?? [] as $album){ |
|
81 | + foreach ($artistAlbums->items ?? [] as $album) { |
|
82 | 82 | $rdate = strtotime($album->release_date); |
83 | 83 | |
84 | - if($album->release_date_precision === 'day' && $rdate >= $since && $rdate <= $until){ |
|
84 | + if ($album->release_date_precision === 'day' && $rdate >= $since && $rdate <= $until) { |
|
85 | 85 | |
86 | 86 | // skip the "Various Artists" samplers |
87 | - if(isset($album->artists) && !empty($album->artists) && strtolower($album->artists[0]->name) === 'various artists'){ |
|
87 | + if (isset($album->artists) && !empty($album->artists) && strtolower($album->artists[0]->name) === 'various artists') { |
|
88 | 88 | continue; |
89 | 89 | } |
90 | 90 | |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | // fetch the album tracks (why aren't the tracks in the artistAlbums response???) |
103 | -foreach(array_chunk($newalbums, 20, true) as $chunk){ // API max = 20 albums |
|
103 | +foreach (array_chunk($newalbums, 20, true) as $chunk) { // API max = 20 albums |
|
104 | 104 | $albums = Psr7\get_json($spotify->albums(['ids' => implode(',', $chunk), 'market' => $market])); |
105 | 105 | |
106 | - foreach($albums->albums ?? [] as $album){ |
|
106 | + foreach ($albums->albums ?? [] as $album) { |
|
107 | 107 | $tracks = array_column($album->tracks->items, 'id'); |
108 | 108 | # shuffle($tracks); |
109 | 109 | |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | ); |
128 | 128 | |
129 | 129 | // add the tracks to the playlist |
130 | -$uris = array_map(function($t){ |
|
130 | +$uris = array_map(function($t) { |
|
131 | 131 | return 'spotify:track:'.$t; // why not just ids??? |
132 | 132 | }, $newtracks); |
133 | 133 | |
134 | -$uris = array_chunk($uris, 100); // API max = 100 track URIs |
|
134 | +$uris = array_chunk($uris, 100); // API max = 100 track URIs |
|
135 | 135 | |
136 | -foreach($uris as $i => $chunk){ |
|
136 | +foreach ($uris as $i => $chunk) { |
|
137 | 137 | $playlistAddTracks = $spotify->playlistAddTracks($me->id, $playlistCreate->id, ['uris' => $chunk]); |
138 | 138 | |
139 | 139 | $playlistAddTracks->getStatusCode() === 201 |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | // sort the $releaseinfo array by release date (descending) |
145 | 145 | krsort($releaseinfo); |
146 | 146 | |
147 | -foreach($releaseinfo as $y => $year){ |
|
147 | +foreach ($releaseinfo as $y => $year) { |
|
148 | 148 | krsort($year); |
149 | 149 | |
150 | - foreach($year as $m => $month){ |
|
150 | + foreach ($year as $m => $month) { |
|
151 | 151 | krsort($month); |
152 | 152 | |
153 | - foreach($month as $d => $day){ |
|
153 | + foreach ($month as $d => $day) { |
|
154 | 154 | sort($day); |
155 | 155 | |
156 | 156 | $logger->info(''); |
157 | 157 | $logger->info('--- '.date('l, jS F Y\:', mktime(0, 0, 0, $m, $d, $y)).' ---'); |
158 | 158 | $logger->info(''); |
159 | 159 | |
160 | - foreach($day as $id => $release){ |
|
160 | + foreach ($day as $id => $release) { |
|
161 | 161 | $logger->info('['.++$id.'] '.implode(', ', array_column($release->artists, 'name')).' - '.$release->name); |
162 | 162 | } |
163 | 163 | } |
@@ -64,8 +64,7 @@ |
||
64 | 64 | break; |
65 | 65 | } |
66 | 66 | |
67 | - } |
|
68 | - elseif(isset($data->error)){ |
|
67 | + } elseif(isset($data->error)){ |
|
69 | 68 | $logger->error($data->error->message.' ('.$data->error->status.')'); |
70 | 69 | # throw new \Exception($data->error->message, $data->error->status); |
71 | 70 | } |
@@ -154,7 +154,7 @@ |
||
154 | 154 | 'collaborative' => false, |
155 | 155 | // can you please autolink Spotify URIs in the description? |
156 | 156 | 'description' => 'Playlist morphed from spotify:user:'.$playlist_user.':playlist:'.$playlist_id.' ['.$hash.']' |
157 | - .(!empty($userPlaylist->description) ? '('.$userPlaylist->description.')' : ''), |
|
157 | + .(!empty($userPlaylist->description) ? '('.$userPlaylist->description.')' : ''), |
|
158 | 158 | ])); |
159 | 159 | |
160 | 160 | $logger->info('created playlist: '.$playlistname.' ('.count($newtracks).' tracks total)'); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $sleeptimer = 250000; // sleep between requests (µs) |
45 | 45 | |
46 | 46 | // fetch all tracks of a given playlist, including artist & album ids |
47 | -while(true){ |
|
47 | +while (true) { |
|
48 | 48 | $userPlaylistTracks = Psr7\get_json($spotify->userPlaylistTracks($playlist_user, $playlist_id, [ |
49 | 49 | 'fields' => 'total,items(track(id,name,album(id),artists(id,name)))', |
50 | 50 | 'offset' => $offset, |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | 'market' => $market, |
53 | 53 | ])); |
54 | 54 | |
55 | - foreach($userPlaylistTracks->items as $t){ |
|
55 | + foreach ($userPlaylistTracks->items as $t) { |
|
56 | 56 | $track = $t->track->id; |
57 | 57 | $artist = $t->track->artists[0]; |
58 | 58 | |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | // crawl through the pagination |
67 | - if($userPlaylistTracks->total ?? false){ |
|
67 | + if ($userPlaylistTracks->total ?? false) { |
|
68 | 68 | $offset += $limit; |
69 | 69 | |
70 | - if($offset > $userPlaylistTracks->total || $offset >= $max_size){ |
|
70 | + if ($offset > $userPlaylistTracks->total || $offset >= $max_size) { |
|
71 | 71 | break; |
72 | 72 | } |
73 | 73 | } |
@@ -76,27 +76,27 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | // now fetch the tracklist for each track's album |
79 | -foreach(array_chunk($oldalbums, 20, true) as $chunk){ // API max = 20 albums |
|
79 | +foreach (array_chunk($oldalbums, 20, true) as $chunk) { // API max = 20 albums |
|
80 | 80 | $albums = Psr7\get_json($spotify->albums(['ids' => implode(',', $chunk), 'market' => $market])); |
81 | 81 | |
82 | - if(!isset($albums->albums)){ |
|
82 | + if (!isset($albums->albums)) { |
|
83 | 83 | $logger->error('expected album list, got nothing'); |
84 | 84 | continue; |
85 | 85 | } |
86 | 86 | |
87 | - foreach(array_combine(array_keys($chunk), $albums->albums) as $oldtrack_id => $album){ |
|
87 | + foreach (array_combine(array_keys($chunk), $albums->albums) as $oldtrack_id => $album) { |
|
88 | 88 | |
89 | - if(!isset($album->tracks)){ |
|
89 | + if (!isset($album->tracks)) { |
|
90 | 90 | continue; |
91 | 91 | } |
92 | 92 | |
93 | 93 | // diff the old track against the album tracks |
94 | 94 | $diff = array_diff(array_column($album->tracks->items, 'id'), [$oldtrack_id]); |
95 | 95 | |
96 | - if(!empty($diff)){ |
|
96 | + if (!empty($diff)) { |
|
97 | 97 | // randomize the leftover tracks and pick the first |
98 | 98 | shuffle($diff); |
99 | - $newtracks[$oldtrack_id] = array_shift($diff); |
|
99 | + $newtracks[$oldtrack_id] = array_shift($diff); |
|
100 | 100 | $logger->info('+ ['.$trackinfo[$oldtrack_id].']'); |
101 | 101 | |
102 | 102 | continue; |
@@ -112,14 +112,14 @@ discard block |
||
112 | 112 | |
113 | 113 | usleep($sleeptimer); |
114 | 114 | |
115 | - if(!isset($artistAlbums->items)){ |
|
115 | + if (!isset($artistAlbums->items)) { |
|
116 | 116 | continue; |
117 | 117 | } |
118 | 118 | |
119 | 119 | // diff the old album vs the artist's albums |
120 | 120 | $artistAlbums = array_diff(array_column($artistAlbums->items, 'id'), [$album->id]); |
121 | 121 | |
122 | - if(empty($artistAlbums)){ |
|
122 | + if (empty($artistAlbums)) { |
|
123 | 123 | continue; |
124 | 124 | } |
125 | 125 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | // WTB bulk endpoint /albums/tracks?ids=album_id1,album_id2,... |
130 | 130 | $albumTracks = Psr7\get_json($spotify->albumTracks(array_shift($artistAlbums), ['market' => $market])); |
131 | 131 | |
132 | - if(isset($albumTracks->items)){ |
|
132 | + if (isset($albumTracks->items)) { |
|
133 | 133 | shuffle($albumTracks->items); |
134 | 134 | } |
135 | 135 | |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | $logger->info('https://open.spotify.com/user/'.$me->id.'/playlist/'.$playlistCreate->id); |
163 | 163 | |
164 | 164 | // create the URIs for playlistAddTracks |
165 | -$uris = array_chunk(array_map(function($t){ |
|
165 | +$uris = array_chunk(array_map(function($t) { |
|
166 | 166 | return 'spotify:track:'.$t; // why not just ids??? |
167 | -}, $newtracks), 100); // API max = 100 track URIs |
|
167 | +}, $newtracks), 100); // API max = 100 track URIs |
|
168 | 168 | |
169 | 169 | // add the tracks |
170 | -foreach($uris as $i => $chunk){ |
|
170 | +foreach ($uris as $i => $chunk) { |
|
171 | 171 | $playlistAddTracks = $spotify->playlistAddTracks($me->id, $playlistCreate->id, ['uris' => $chunk]); |
172 | 172 | |
173 | 173 | $playlistAddTracks->getStatusCode() === 201 |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $api[] = ['path' => '/v2/wvw/upgrades/:id', 'lang' => true, 'auth' => false, 'active' => true]; |
95 | 95 | |
96 | 96 | |
97 | -foreach($api as $endpoint){ |
|
97 | +foreach ($api as $endpoint) { |
|
98 | 98 | $query = []; |
99 | 99 | $path_elements = []; |
100 | 100 | $path = explode('/', trim($endpoint['path'], '/v2 ')); |
@@ -102,16 +102,16 @@ discard block |
||
102 | 102 | |
103 | 103 | |
104 | 104 | $i = 1; |
105 | - foreach($path as $k => $el){ |
|
105 | + foreach ($path as $k => $el) { |
|
106 | 106 | $name[$k] = ucfirst($el); |
107 | 107 | |
108 | 108 | $x = explode('?', $el); |
109 | 109 | |
110 | - if(count($x) === 2){ |
|
110 | + if (count($x) === 2) { |
|
111 | 111 | $query = array_merge($query, explode('&', $x[1])); |
112 | 112 | } |
113 | 113 | |
114 | - if(strpos($el, ':') === 0){ |
|
114 | + if (strpos($el, ':') === 0) { |
|
115 | 115 | $pe = substr($el, 1); |
116 | 116 | $path_elements[] = substr($el, 1); |
117 | 117 | $path[$k] = '%'.$i.'$s'; |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | - if((bool)$endpoint['lang']){ |
|
123 | + if ((bool)$endpoint['lang']) { |
|
124 | 124 | $query[] = 'lang'; |
125 | 125 | } |
126 | 126 | |
127 | - if((bool)$endpoint['auth']){ |
|
127 | + if ((bool)$endpoint['auth']) { |
|
128 | 128 | $query[] = 'access_token'; |
129 | 129 | } |
130 | 130 | |
131 | - if(!(bool)$endpoint['active']){ |
|
131 | + if (!(bool)$endpoint['active']) { |
|
132 | 132 | continue; |
133 | 133 | } |
134 | 134 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | $str = []; |
145 | 145 | |
146 | -foreach($apiMethods as $method => $args){ |
|
146 | +foreach ($apiMethods as $method => $args) { |
|
147 | 147 | // create a docblock |
148 | 148 | // @todo |
149 | 149 | $str[] = ' |
@@ -12,18 +12,18 @@ discard block |
||
12 | 12 | use chillerlan\HTTP\Psr7; |
13 | 13 | |
14 | 14 | /** @var \chillerlan\OAuth\Providers\Twitter\Twitter $twitter */ |
15 | -$twitter = null; |
|
15 | +$twitter = null; |
|
16 | 16 | |
17 | 17 | require_once __DIR__.'/twitter-common.php'; |
18 | 18 | |
19 | 19 | $servicename = $twitter->serviceName; |
20 | 20 | |
21 | 21 | // step 2: redirect to the provider's login screen |
22 | -if(isset($_GET['login']) && $_GET['login'] === $servicename){ |
|
22 | +if (isset($_GET['login']) && $_GET['login'] === $servicename) { |
|
23 | 23 | header('Location: '.$twitter->getAuthURL()); |
24 | 24 | } |
25 | 25 | // step 3: receive the access token |
26 | -elseif(isset($_GET['oauth_token']) && isset($_GET['oauth_verifier'])){ |
|
26 | +elseif (isset($_GET['oauth_token']) && isset($_GET['oauth_verifier'])) { |
|
27 | 27 | $token = $twitter->getAccessToken($_GET['oauth_token'], $_GET['oauth_verifier']); |
28 | 28 | |
29 | 29 | // save the token [...] |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | header('Location: ?granted='.$servicename); |
35 | 35 | } |
36 | 36 | // step 4: verify the token and use the API |
37 | -elseif(isset($_GET['granted']) && $_GET['granted'] === $servicename){ |
|
37 | +elseif (isset($_GET['granted']) && $_GET['granted'] === $servicename) { |
|
38 | 38 | echo '<pre>'.print_r(Psr7\get_json($twitter->verifyCredentials()), true).'</pre>'; |
39 | 39 | } |
40 | 40 | // step 1 (optional): display a login link |
41 | -else{ |
|
41 | +else { |
|
42 | 42 | echo '<a href="?login='.$servicename.'">connect with '.$servicename.'!</a>'; |
43 | 43 | } |
44 | 44 |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | $servicename = $tumblr->serviceName; |
20 | 20 | |
21 | 21 | // step 2: redirect to the provider's login screen |
22 | -if(isset($_GET['login']) && $_GET['login'] === $servicename){ |
|
22 | +if (isset($_GET['login']) && $_GET['login'] === $servicename) { |
|
23 | 23 | header('Location: '.$tumblr->getAuthURL()); |
24 | 24 | } |
25 | 25 | // step 3: receive the access token |
26 | -elseif(isset($_GET['oauth_token']) && isset($_GET['oauth_verifier'])){ |
|
26 | +elseif (isset($_GET['oauth_token']) && isset($_GET['oauth_verifier'])) { |
|
27 | 27 | $token = $tumblr->getAccessToken($_GET['oauth_token'], $_GET['oauth_verifier']); |
28 | 28 | |
29 | 29 | // save the token [...] |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | header('Location: ?granted='.$servicename); |
33 | 33 | } |
34 | 34 | // step 4: verify the token and use the API |
35 | -elseif(isset($_GET['granted']) && $_GET['granted'] === $servicename){ |
|
36 | - echo '<pre>'.print_r(Psr7\get_json($tumblr->me()),true).'</pre>'; |
|
35 | +elseif (isset($_GET['granted']) && $_GET['granted'] === $servicename) { |
|
36 | + echo '<pre>'.print_r(Psr7\get_json($tumblr->me()), true).'</pre>'; |
|
37 | 37 | } |
38 | 38 | // step 1 (optional): display a login link |
39 | -else{ |
|
39 | +else { |
|
40 | 40 | echo '<a href="?login='.$servicename.'">connect with '.$servicename.'!</a>'; |
41 | 41 | } |
42 | 42 |