Hello There, Guest! Register

MySubscriptions 2.3.4 released.
Looking for a custom plugin for your site? Ask here for a quote.

Assistance With Virtual Stock Market Plugin
#1

My Admin who is assisting me on my website does not have an account on MyBB-Plugins.com, but I do and I am using your Newpoints plugin.

So, he has this question regarding the plugin.

Oh yea... I should mention that he's using CoinMarketCap as the source to get the API from.
But, it can be from any API from any stock related website.

Thanks!  Cool

0xB9 Wrote:I'm trying to get data from an API to show for the price of stocks.

I added this code into the virtualstock.php file
PHP Code:
function cryptoData()
{
   global $mybb$cache$db$lang$cryptoData;
     $url "https://api.coinmarketcap.com/v1/ticker/";

 $json file_get_contents($url);
 $data json_decode($jsonTRUE);

// Bitcoin price
 $btcprice $data[0]["price_usd"];
 $usd_price 10;
 $bitcoin_price round$usd_price $btcprice 8);


So it now looks like this
PHP Code:
$categories[0] = $lang->virtualstock_select_cat;

function 
cryptoData()
{
   global $mybb$cache$db$lang$cryptoData;
     $url "https://api.coinmarketcap.com/v1/ticker/";

 $json file_get_contents($url);
 $data json_decode($jsonTRUE);

// Bitcoin price
 $btcprice $data[0]["price_usd"];
 $usd_price 10;
 $bitcoin_price round$usd_price $btcprice 8);
}

$query $db->simple_select('virtualstock_categories''*');
while (
$cat $db->fetch_array($query))
$categories[$cat['cid']] = $cat['name'];

$form = new Form("index.php?module=newpoints-virtualstock&action=do_addcompany""post""virtualstock");

$form_container = new FormContainer($lang->virtualstock_addcompany);
$form_container->output_row($lang->virtualstock_addedit_company_name."<em>*</em>"$lang->virtualstock_addedit_company_name_desc$form->generate_text_box('name''', array('id' => 'name')), 'name');
$form_container->output_row($lang->virtualstock_addedit_company_description$lang->virtualstock_addedit_company_description_desc$form->generate_text_box('description''', array('id' => 'description')), 'description');
$form_container->output_row($lang->virtualstock_addedit_company_price$lang->virtualstock_addedit_company_price_desc$form->generate_select_box('price'$btcprice, array('id' => 'price')), 'price');
$form_container->output_row($lang->virtualstock_addedit_company_icon$lang->virtualstock_addedit_company_icon_desc$form->generate_text_box('icon''', array('id' => 'icon')), 'icon');
$form_container->output_row($lang->virtualstock_addedit_company_disporder$lang->virtualstock_addedit_company_disporder_desc$form->generate_text_box('disporder''0', array('id' => 'disporder')), 'disporder');
$form_container->output_row($lang->virtualstock_addedit_company_total$lang->virtualstock_addedit_company_total_desc$form->generate_text_box('total'1000, array('id' => 'total')), 'total');
$form_container->output_row($lang->virtualstock_addedit_company_available$lang->virtualstock_addedit_company_available_desc$form->generate_text_box('available'1000, array('id' => 'available')), 'total');
$form_container->output_row($lang->virtualstock_addedit_company_visible$lang->virtualstock_addedit_company_visible_desc$form->generate_yes_no_radio('visible'1true""""), 'visible');
$form_container->output_row($lang->virtualstock_addedit_company_category."<em>*</em>"$lang->virtualstock_addedit_company_category_desc$form->generate_select_box('cid'$categories$cid, array('id' => 'cid')), 'cid'); 

My problem is I'm not sure how to get the data from the API to show in the price, so the line I need help with is this
PHP Code:
$form_container->output_row($lang->virtualstock_addedit_company_price$lang->virtualstock_addedit_company_price_desc$form->generate_select_box('price'$btcprice, array('id' => 'price')), 'price'); 

Not sure how I would add the data into that line for it to work correctly.
Any help would be awesome, thanks!
Reply


Messages In This Thread
Assistance With Virtual Stock Market Plugin - by Serpius - 08-25-2018, 10:10 PM



Users browsing this thread: 1 Guest(s)