File tree Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Original file line number Diff line number Diff line change 7
7
+ event.getShouts
8
8
+ event.shout
9
9
+ user.getShouts
10
+ + user.shout
10
11
* Fixed badly formed XML errors appearing. Will return error 95 when it happens. It is up to the application to
11
12
decide how to handle the error. Thank you to her035 for the advice on how to fix it and the nice example
12
13
that was made for me (http://her035.de/lastfm/test/xml.php). Much appreciated!
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ // Include the API
4
+ require '../../lastfmapi/lastfmapi.php ' ;
5
+
6
+ // Get the session auth data
7
+ $ file = fopen ('../auth.txt ' , 'r ' );
8
+ // Put the auth data into an array
9
+ $ authVars = array (
10
+ 'apiKey ' => trim (fgets ($ file )),
11
+ 'secret ' => trim (fgets ($ file )),
12
+ 'username ' => trim (fgets ($ file )),
13
+ 'sessionKey ' => trim (fgets ($ file )),
14
+ 'subscriber ' => trim (fgets ($ file ))
15
+ );
16
+ $ config = array (
17
+ 'enabled ' => true ,
18
+ 'path ' => '../../lastfmapi/ ' ,
19
+ 'cache_length ' => 1800
20
+ );
21
+ // Pass the array to the auth class to eturn a valid auth
22
+ $ auth = new lastfmApiAuth ('setsession ' , $ authVars );
23
+
24
+ $ apiClass = new lastfmApi ();
25
+ $ userClass = $ apiClass ->getPackage ($ auth , 'user ' , $ config );
26
+
27
+ // Setup the variables
28
+ $ methodVars = array (
29
+ 'user ' => 'lotrgamemast ' ,
30
+ 'message ' => 'Looks like someone just ran the user.shout example '
31
+ );
32
+
33
+ if ( $ userClass ->shout ($ methodVars ) ) {
34
+ echo '<b>Done</b> ' ;
35
+ }
36
+ else {
37
+ die ('<b>Error ' .$ userClass ->error ['code ' ].' - </b><i> ' .$ userClass ->error ['desc ' ].'</i> ' );
38
+ }
39
+
40
+ ?>
Original file line number Diff line number Diff line change @@ -917,6 +917,41 @@ public function getWeeklyTrackChart($methodVars) {
917
917
return FALSE ;
918
918
}
919
919
}
920
+
921
+ public function shout ($ methodVars ) {
922
+ // Only allow full authed calls
923
+ if ( $ this ->fullAuth == TRUE ) {
924
+ // Check for required variables
925
+ if ( !empty ($ methodVars ['user ' ]) && !empty ($ methodVars ['message ' ]) ) {
926
+ $ vars = array (
927
+ 'method ' => 'user.shout ' ,
928
+ 'api_key ' => $ this ->auth ->apiKey ,
929
+ 'user ' => $ methodVars ['user ' ],
930
+ 'message ' => $ methodVars ['message ' ],
931
+ 'sk ' => $ this ->auth ->sessionKey
932
+ );
933
+ $ sig = $ this ->apiSig ($ this ->auth ->secret , $ vars );
934
+ $ vars ['api_sig ' ] = $ sig ;
935
+
936
+ if ( $ call = $ this ->apiPostCall ($ vars ) ) {
937
+ return TRUE ;
938
+ }
939
+ else {
940
+ return FALSE ;
941
+ }
942
+ }
943
+ else {
944
+ // Give a 91 error if incorrect variables are used
945
+ $ this ->handleError (91 , 'You must include user and message variables in the call for this method ' );
946
+ return FALSE ;
947
+ }
948
+ }
949
+ else {
950
+ // Give a 92 error if not fully authed
951
+ $ this ->handleError (92 , 'Method requires full auth. Call auth.getSession using lastfmApiAuth class ' );
952
+ return FALSE ;
953
+ }
954
+ }
920
955
}
921
956
922
957
?>
You can’t perform that action at this time.
0 commit comments