The website is for sale. Check here for more information.
This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.
Assistance With Virtual Stock Market Plugin
#1
Exclamation 
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

Unfortunately you do not have sufficient rights to view replies in this thread. For full access, consider upgrading .






Users browsing this thread: 1 Guest(s)

About MyBB-Plugins

Plug Yourself into the best MyBB AddOn.

Copyright © 2009-2021 MyBB-Plugins Forums.

Statistics

  • 51,000+ Posts
  • 19,000+ Members
  • 3,600+ Threads

Impressed? For sure
Check Full Stats here