This post will from now on be used as the archive of old content.
All content herein is just for the record. Especially the PAL script shown here will no longer work!Mastacheata wrote:
Hello,
I've played around with the facebook API today and would like to test my application in a larger scale.
For now it only changes the users status message to the display the currently playing song.
Planned is to extend this to dedications/requests from the phpweb and eventually posting the album art on facebook too.
Any Ideas for other social networks are welcome. (I've already seen twitter out there and I plan on adding the VZNetzwerke [German facebook copy])
I just registered on facebook and don't know if any of my friends are registered there at all, otherwise I would attack them

(I'm living in Germany, here most people don't use facebook)
It should be possible to send messages from SAM to any facebook account if the owner accepts to.
The Service is some kind of hybrid. Since the facebook API is kinda complicated and only accepts input via post it's nearly impossible to realize in PAL.
I'll host a php script that does the real work talking to facebook and registered users can call that script from PAL via WebToString.
I'll publish the PAL Script here when it's tested and approved.
For now you can ask me via PM and use my PHP Service.
Here you can register for the Beta test. (You Approve that my application may post messages to your feed without prior notification, but can revoke that in your profile settings at any time)
Please Login to Facebook first, otherwise this might not work as expected (Your userid is stored in my database. I don't know if it's possible to get a list of authorized users otherwise)
Thank you very much in advance
Mastacheata wrote:
Now I've got 6 or 7 people open the page and 3 of them accepted my application.
I'd like to say thank you to all who even bothered to read this and open my app's page.
I'm sorry to bother you again, but since most people's "walls" are not public I can't manually see if my app did what it was supposed to.
(My application may read your walls, but since that would render all your privacy settings useless I won't write any code that does such a thing)
Would you please be so kind and tell me here, when you see the following message (Or anything that looks similar) on your wall (best with screenshot):
Code:
Thank you for beta testing the Sam Broadcaster Facebook API
If you've seen this message on your facebook wall, would you please be so kind and report back to me at the Spacialaudio Forums.
Thank You
EDIT: Status Update: App is now able to post images (PHP Side). If the base adress of your image folder is available on the net and known to the app it will be possible to post the album art to facebook.
PAL Sourcecode will be published after 3 successful reports. (You can use my php service from that point)
This is only here for archival purposes!
Mastacheata wrote:
3 Posts in a row now. Seems like noone's really interested in this app?
The rudimentary Song Info Posting works well enough to present it to the public.
If you like you can test it now using my Server. Configuration is explained in the PAL Script.
Code:
{## Facebook Poster v0.10}
///////////////////////////////////////////////////////////////////
// License Agreement or Nettiquette //
// You may use this PAL Script to communicate with my server //
// Change it to your like but don't flood the server/facebook //
// //
// Also make sure you don't post any inappropriate messages //
// Either me or facebook might then cease to run this service //
// //
// This service has no guaranteed uptime nor support //
// However you may ask Questions in the Spacialaudio Forums //
// I will probably come back to you and help //
// //
// The Webservice talking with facebook will stay private //
// At least until its completely done and tidied up //
// //
// To Register just go to following Website, login to facebook //
// you will be shown 3 different pages where you have to click //
// Accept / Allow at the bottom of each page //
// If something went wrong you can always start over //
// //
// http://apps.facebook.com/sambcsonginfo/? //
///////////////////////////////////////////////////////////////////
var Player : TPlayer;
var Song : TSongInfo;
var facebookmessage, returnmessage, logdir, threshold, userid, network : String;
var ErrorLog, DebugLog : TStrings;
///////////////////////////////////////////////////////////////////
// User Configuration Area //
///////////////////////////////////////////////////////////////////
// SAM will create 2 Logfiles: //
// facebook.log contains the IDs of successful postings //
// facebook.err contains the Error Codes if something went wrong //
// IMPORTANT: Keep the trailing backslash (\) !!! //
// //
// Jingle Threshold: //
// Every Title shorter than the threshold will not be published //
// //
// User ID: //
// Your Facebook User ID (Number with up to 20 digits //
// You'll get that when you register with the app //
// //
// Network: //
// facebook is the only working input here //
// Further options will be added here later //
///////////////////////////////////////////////////////////////////
// //
{} logdir := 'C:\Program Files (x86)\SpacialAudio\SAMBC\'; {}
{} threshold := '+00:00:25'; {}
{} userid := 'CHANGEME'; {}
{} network := 'facebook'; {}
// //
///////////////////////////////////////////////////////////////////
// No Changes below this Point unless you know what you do. //
///////////////////////////////////////////////////////////////////
PAL.Loop := true;
// URL Encode
// Replaces non Alphanumeric symbols by their numeric representation
// and converts that one to hex prepending the % sign
function urlencode(S: string): string;
begin
var Idx : integer;
var tvar : integer;
result := '';
if (Length(S)) > 0 then begin
For Idx := 1 to length(S) do
begin
tvar := Ord(S[Idx]);
if ((tvar > 47) and (tvar < 58)) or ((tvar > 64) and (tvar < 91)) or ((tvar > 96) and (tvar < 123)) Then
begin
result := result + (S[Idx])
end
else
begin
result := result + '%' + IntToHex(Ord(S[Idx]),2);
end;
end;
end;
end;
// Append to File is not possible so we have to load the old contents.
ErrorLog.LoadFromFile(logdir + 'facebook.err');
DebugLog.LoadFromFile(logdir + 'facebook.log');
Player := ActivePlayer;
// Is anything playing right now?
IF ( Player <> NIL ) THEN
BEGIN
Song := Player.GetSongInfo;
// Message to display in Facebook
facebookmessage := Song['title'] + ' - ' + Song['artist'];
// URLEncode Blanks
PAL.LockExecution;
facebookmessage := urlencode(facebookmessage);
PAL.UnlockExecution;
// Here goes the magic!
returnmessage := WebToStr('http://www.xenzilla.de/radioscript/'
+ '?message=' + facebookmessage + '&userid=' + userid + '&dest=' + network);
// Errormessages don't contain the underscore
IF ( Pos('_', returnmessage) = 0 ) THEN
BEGIN
returnmessage := DateTimeToStr(NOW) + ' ' + returnmessage;
Writeln(returnmessage);
ErrorLog.Add(returnmessage);
ErrorLog.SaveToFile(logdir + 'facebook.err');
END
// For debugging purposes Successful Posts will be logged too
ELSE
BEGIN
returnmessage := DateTimeToStr(NOW) + ' ' + returnmessage;
Writeln(returnmessage);
DebugLog.Add(returnmessage);
DebugLog.SaveToFile(logdir + 'facebook.log');
END;
END;
// Alll done wait for track change
PAL.WaitForPlayCount(1);
// Jingles & Co will not be posted, if shorter than threshold (adjustable)
PAL.WaitForTime(threshold);
Please use it wisely. If you post spam or things that are against facebooks TOS, the service will cease to exist.