So I'm attempting to build a wordpress plugin that handles donations, and while I could work with the paypal API myself, I'd rather my potential donators know that they are donating straight to the server, so I intend to essentially have this plugin link directly to the nfo donate.pl system.
Now, obviously within my own control panel I can view the coffer, but is there a way I could have my wordpress plugin retrieve the current coffer? (Is there an externally accessible API that allows me to do this?)
I essentially want to display a [current coffer] out of [total cost] on my page and use the NFO systems for donation.
Retrieve Coffer
-
- This is my homepage
- Posts: 353
- https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
- Joined: Fri Sep 17, 2004 7:50 pm
- Contact:
- Vanderburg
- Former staff
- Posts: 1253
- Joined: Sat Nov 13, 2010 7:27 am
- Location: Dallas, TX
Re: Retrieve Coffer
This is something that has been suggested in the past, but there's no current API for this. Currently, the only way you'd be able to get this is to have a plugin or script pass the HTTP auth for the control panel and pull that information off the Payments tab.
-
- This is my homepage
- Posts: 353
- Joined: Fri Sep 17, 2004 7:50 pm
- Contact:
Re: Retrieve Coffer
That is a really really inefficient way to do things... but I guess I can do it that way.
-
- This is my homepage
- Posts: 353
- Joined: Fri Sep 17, 2004 7:50 pm
- Contact:
Re: Retrieve Coffer
For anyone who wishes future reference, here is what I ended up coming up with (took a long time)
$nfod_currentcoffer will have the value of your current coffer stored. You could always turn this into a function, but I only needed it stored in a variable myself.
I bet there's a little redundancy in the auth methods there too, but I can't be certain.
Code: Select all
<?php
//Get NFO Data
$username = "EMAIL";
$password = "PASSWORD";
$geturl = "https://www.nfoservers.com/control/account_payments.pl";
$refurl = "https://www.nfoservers.com/control/account_payments.pl";
$params = "email=" . $username . "&" . "password=" . $password;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $geturl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile"); # SAME cookiefile
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_REFERER, $ref_url);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, true);
//curl_setopt($ch, CURLOPT_POST, true);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$nfod_currentcoffer = nfod_get_string_between($output, "<b style='font-size:16pt'>","</b>");
function nfod_get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
$nfod_currentcoffer will have the value of your current coffer stored. You could always turn this into a function, but I only needed it stored in a variable myself.
I bet there's a little redundancy in the auth methods there too, but I can't be certain.
-
- This is my homepage
- Posts: 353
- Joined: Fri Sep 17, 2004 7:50 pm
- Contact:
Re: Retrieve Coffer
Making use of this feature inside a wordpress plugin I put together:
(If linking is allowed)
http://brbu.site.nfoservers.com/wordpress/
I've even worked in a width setting to the display's background that is based on essentially what would be a graphical representation of the percentage of total cost covered by the coffer.
(If linking is allowed)
http://brbu.site.nfoservers.com/wordpress/
I've even worked in a width setting to the display's background that is based on essentially what would be a graphical representation of the percentage of total cost covered by the coffer.
Re: Retrieve Coffer
We don't officially support automated tools using the control panel, and the Payments page is a particularly intensive one for us to create server-side. If you plan to pull data from it, you need to make sure that you're only doing it rarely (such as once a day) and properly caching the result.
-
- This is my homepage
- Posts: 353
- Joined: Fri Sep 17, 2004 7:50 pm
- Contact:
Re: Retrieve Coffer
Alright, I'll make it handle that way through a cron job. Still it'd be nice to have an API with access.
Re: Retrieve Coffer
Sorry to necro this old thread but didn't see a point in making another thread about it.
Would it be possible for NFO to just supply a once a day updated PNG generating php/perl/python script(or any other image) with the current coffer total? Possibly make it a feature of the web hosting, VDS rental, dedicated rental or something of the sort?
Since this would be somewhat additionally taxing on the NFO servers if everyone were to poll for this data on each page load, I don't want to use the curl method that was provided in this thread but I would like some way to put this data out.
I am switching from doing server donations through a paypal goal widget to going directly through NFO for the donations to make things easier on my community and myself.
Has there been any better effort put towards this or is it pretty much still sitting at the point that it was left at here? I haven't been able to find too many other relevant threads with actual information in them.
Thanks in advance Edge and Co.
Would it be possible for NFO to just supply a once a day updated PNG generating php/perl/python script(or any other image) with the current coffer total? Possibly make it a feature of the web hosting, VDS rental, dedicated rental or something of the sort?
Since this would be somewhat additionally taxing on the NFO servers if everyone were to poll for this data on each page load, I don't want to use the curl method that was provided in this thread but I would like some way to put this data out.
I am switching from doing server donations through a paypal goal widget to going directly through NFO for the donations to make things easier on my community and myself.
Has there been any better effort put towards this or is it pretty much still sitting at the point that it was left at here? I haven't been able to find too many other relevant threads with actual information in them.
Thanks in advance Edge and Co.