Introduction - Player
  Introduction - Members Only
  Introduction - Administration
  Getting Started
  Calendar
  Results
 Handicap
 Results (Amend/Delete)
 Results (Download)
 Multiple Events
 Personal Analysis
 Recover Results Files
 Upload (ACBL)
 Upload (ACBL Player DB)
 Upload (EBUScore)
 Upload (PairsScorer)
 Upload (ScoreBridge)
 Upload (ScorePost)
 Upload (EBU USEBIO)
 Upload (Web Site)
 Live Ranking
 ACBL Masterpoints
 Import
 API Interface
 Windows Firewall
  Displaying Hands
  News
  Competitions
  Settings
  Menu
  Picture Library
  Document Library
  Membership
  Other Features
  Miscellaneous
  Release Notes
BridgeWebs User Guide & Help
Results - API Interface

Direct Results Upload API (HTTP Post Extension):

The results files can be uploaded through the web site, but for software developers it is possible to use an HTTP post directive to post the files directly rather than use FTP.

An HTTP post basically does what a user would do by going to a web page and clicking submit with the fields filled in.

The reply can be read to see what happened and parse "message = xxxxx" to find the status.

Your Software

It will be necessary to provide an option for the user to enter the Club Code instead of "myclub" and their Bridgewebs club "password" in the software Options/Configuration file somewhere.

Then provide suitable buttons [Upload to BridgeWebs] etc. somewhere on the Results page to execute the transfer

See below for VB or Perl example..

Results Upload API

To upload the results with attachments, the parameters are:

club      = myclub
password  = secret
type      = upload
filename  = xxxxxxxx.csv
event_id = N (if known, see Calendar below)
data      = a string of all the lines of the xxxxxxxx.csv file
dealname  = xxxxxxxx.dlm (can be dlm, bri, pbn, dup)
dealdata  = a string of all the lines of the xxxxxxxx.dlm file
dealXname = xxxxxxxx.dlm (can be dlm, bri, pbn, dup) } Where X is 2-9 for extra sessions.
dealXdata = a string of all the lines of the xxxxxx.dlm file }
infoname  = info.pdf (PDF supporting Info file)
infodata  = a string of all the lines of the info.pdf file
// for ACBL Uploads
acblname  = ACBL file name 140709.ACA (as necessary)
acbldata  = a string of all the lines of the ACBL file
bwsname   = BWS file name 140709.ACA (as necessary)
bwsdata   = a string of all the lines of the BWS file

The data of the files can be strung together from the file and put it in one field "data" or "handdata" as appropriate. It is as if you cut and paste the file into a web text box. In this case, the filename specified is not actually accessed but is used as the file name when writing the data on the bridgewebs server for consistency with the manual technique.

The reply can be parsed to see what happened.
Parse "message = xxxxx" to find the status.

Player Upload API

To upload the player file, the parameters are:

club     = myclub
password = secret
type     = upload
filename = xxxxxxxx.XXX
data      = a string of all the lines of the xxxxxxxx file

Where XXX is

txt = Scorebridge format
csv = csv format
xml = EBU USEBIO Format

Player Download API

To download the player file, the parameters are:

club     = myclub
password = secret
type     = download
filename = xxxxxxxx.XXX

Where XXX is

txt = Scorebridge format
csv = csv format
xml = EBU USEBIO Format

The reply will contain the player file in a separate line.

message = Download Successful
data = ..............., then split the content of that line replacing ~ (tilde) with \n.

Direct Document Upload API

To just upload a document to the club directory, the parameters are:

club     = myclub
password = secret
type     = upload
transfer = doc
filename = bw.csv
data     = a string of all the lines of the bw.csv file

Hand Upload API

To upload a .pbn deal file and attach to an event, the parameters are:

club     = myclub
password = secret
type     = upload
transfer = deal
event    = YYYYMMDD_X e.g. 20140709_1,
           X is the unique Id of the event for that date, usually 1.
dealname = xxxxxxxx.pbn
dealdata = an encoded string of all the lines of the xxxxxxxx.pbn file

As a safety feature, will fail if the event does not exist. So the club will need to create Calendar entries in advance.

Calendar Download API

To download the club calendar, the parameters are:

club     = myclub
password = secret
type     = download
year = 2014
transfer = cal

This will return a JSON argument of the calendar entries for the YEAR as a pair, id = title, file (if uploaded)

json = {"events":{"201407091":{"file":"2014Jul09!!.dat","title":"Duplicate Pairs"},.....}}

Event Download API

Similar to the Calendar, but just the events for a particular day, the parameters are:

club     = myclub
password = secret
type     = download
transfer = events
date = 20140709 (yyyymmdd)

This will return a JSON argument of the calendar entries for the day as a pair, id = title, file (if uploaded)

json = {"events":{"1":{"file":"2014Jul09!!.dat","title":"Duplicate Pairs"},"2":{"title":"Create New Event"}}}

and a list of events for the day, Title~File uploaded

event_id_1 = Duplicate Pairs~10022_res_2014Aug19!!.dat~
event_id_2 = Create New Event~~

VB API Code

A suitable VB example for doing this can be found at http://www.example-code.com/vb/http_post_form.asp, or just search Google, so that the code would look something like:

Dim h As HTTPClass
Set h = New HTTPClass
Set clubcode = "myclub"
h.Fields("club") = clubcode
h.Fields("password") = "secret"
 ..........
If h.OpenHTTP("www.bridgewebs.com") Then
Debug.Print h.SendRequest("cgi-bin/bwx/api.cgi?club=" & clubcode, "POST")
End If

VB Net Code

A suitable VB class for doing this can be found at https://www.example-code.com/vbscript/http_formSubmitPost.asp, or just search Google, so that the code would look something like:

 

 Public Function GetFromWebSite() As Boolean
'   Get the player database from BridgeWebs
        Cursor.Current = Cursors.WaitCursor
        Dim h As HttpClass
        h = New HttpClass
        Dim x As Integer = 0
        Dim strPost As String = ""
        h.Fields("club") = "my_club"
        h.Fields("type") = "download"
        h.Fields("password") = "password"
        h.Fields("filename") = "players.txt"
        If h.OpenHTTP("www.bridgewebs.com") Then
            strPost = h.SendRequest("cgi-bin/bwx/api.cgi?club=" & "my_club", "POST")
        Else
            '     Provide the error returned from the open call
            MsgBox("Error on HTTP Open " & strPost, vbInformation, "Get from Web")
            Cursor.Current = Cursors.Arrow
            Return False
        End If
        x = InStr(strPost, "Download Successful")
        If x = 0 Then
         '     Provide the error returned from the open call
            MsgBox("HTTP Post operation failed while retrieving Player Database " & vbCrLf & strPost, vbCritical, "Post error")
            Cursor.Current = Cursors.Arrow
            Return False
        End If
        ' The string returned is in the format Data = "......." Message = "Download....."
        ' strip of the text we dont want
       '  Store the text in our global field
        a1.PlayerDownload = Mid(strPost, 8, x - 17)
        Cursor.Current = Cursors.Arrow
        Return True
    End Function

 

PHP API Code

Code for PHP will look something like, but not been tested.

$reply = "";

$clubcode = "myclub";
$data = "club=".urlencode(clubcode);
$data .= "&password=".urlencode("secret");
............
$header = "POST /mailer/send HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($data) . "\r\n\r\n";
$fp = fsockopen('http://www.bridgewebs.com/
cgi-bin/bwx/api.cgi?club=' . $clubcode, 443, $errno, $errstr, 30);

if(!$fp)
   return "ERROR. Could not open connection";
else {
   fputs ($fp, $header.$data);
   while (!feof($fp)) {
     $reply .= fread ($fp, 1024);
   }
 fclose($fp);
 }
 print $reply;

Linux Perl API Code

Code for Perl will look something like, but not been tested.

my $clubcode = 'myclub";
my $url = 'http://www.bridgewebs.com/cgi-bin/bwx/api.cgi?club=' . $clubcode;
my $object = LWP::UserAgent->new;
my $request = $object->post ( $url,
{ 'club' =>$clubcode,
'password' => 'secret',
'type' => 'download',
.........
} );
my $reply = $request->as_string ();
print $reply;

'C' API Code (C# .NET 4.5)

Code for 'C' will look something like, but not been tested.

   async private void cmdUpload_Click(object sender, EventArgs e)
  {
     if (String.IsNullOrEmpty(m_UsebioFile)) // Check if xml file has already been created
     {
         cmdUsebio_Click(this, new EventArgs());  // If not, create it
         if (String.IsNullOrEmpty(m_UsebioFile))
         {
             MessageBox.Show("Failed to create file for upload!", Dashboard.WarningMsgTitle);
             return;
         }
     }
 
     // Create Key/Value pairs for the data
     Dictionary KVPs = new Dictionary(5);
     KVPs.Add("club", ClubID);
     KVPs.Add("password", "password");
     KVPs.Add("type", "upload");
     KVPs.Add("filename", m_UsebioFile);
     KVPs.Add("data", File.ReadAllText(Path.Combine(Properties.Settings.Default.UsebioPath, m_UsebioFile)));
     FormUrlEncodedContent fuec = new FormUrlEncodedContent(KVPs);
 
     HttpClient client = new HttpClient();
     HttpResponseMessage response = await client.PostAsync("http://www.bridgewebs.com/cgi-bin/bwx/api.cgi?club=" + ClubID, fuec);
     if (!response.IsSuccessStatusCode)
         MessageBox.Show("Upload failed!\r   Status Code: " + response.StatusCode.ToString() + "\r   Reason: " + response.ReasonPhrase, Dashboard.WarningMsgTitle,
             MessageBoxButtons.OK,MessageBoxIcon.Warning);
 }