Jump to content

Recommended Posts

This is the json

 

$gtag =  $member['gam_x'];
              $url = "http://www.oldg.co.uk/xboxapi/xboxapi.php?gtag=".urlencode($gtag);
              $output = file_get_contents($url);
              $json = json_decode(utf8_encode($output), true);
              if($json === null) die("Error parsing JSON response (error #".json_last_error().").");
              $online = $json['response'][0]['user']['is_online'];
		  $online_status = $json['response'][0]['user']['online_status'];

 

and i want to call it to

'gamr_x' => $profile['gam_x'],

 

do i just set the json as a function then call it?

Link to comment
https://forums.phpfreaks.com/topic/242547-call-json-to-array/
Share on other sites

i tryed to make  the json script a function

then try and call it like

'gamr_x' => $profile['gam_x']. call_user_func('xgamrinfo'),

 

but that wont work any one have any ideas how i can do this

 

the scrip i am running gets members out of a group, lists so this json call is for about 15 users

Link to comment
https://forums.phpfreaks.com/topic/242547-call-json-to-array/#findComment-1245763
Share on other sites

i am going to have one last go trying to explain what i am trying to do

first part of the code the gamername is the users xbox  gamer id

  while ($profile = $smcFunc['db_fetch_assoc']($query_members))
      {
            $context['display_groups'][$row['place']][$row['id_group']]['members'][$type][] = array(
            'id' => $profile['id_member'],
            'group_id' => $profile['id_group'] . $gamertag,
            'name' => '<span style="color: ' . $row['online_color'] . ';">' . $profile['real_name'] . '</span>',
            'colorless_name' => $profile['real_name'],

		'gamername' => $profile['gamer_xbgt'],     

    'href' => $scripturl . '?action=profile;u=' . $profile['id_member'],
            'link' => '<a href="' . $scripturl . '?action=profile;u=' . $profile['id_member'] . '"><span style="color: ' . $row['online_color'] .             ';">' . $profile['real_name'] . '</span></a>',
            'title' => $profile['usertitle'],
            'online' => array(
               'label' => $txt[$profile['is_online'] ? 'online' : 'offline'],
                $txt[$profile['is_online'] ? 'online' : 'offline'] . '</a>',
                  'image_href' => $settings['images_url'] . '/' . ($profile['is_online'] ? 'useron' : 'useroff') . '.gif',
            ),
         );

      }

 

next bit of the code is the json that that calls the file that scraps the data from xbox.com

$gamertag =  $member['gamername'];
              $url = "http://www.oldg.co.uk/xboxapi/xboxapi.php?gamertag=".urlencode($gamertag);
              $output = file_get_contents($url);
              $json = json_decode(utf8_encode($output), true);

 

 

next bit shows prints the data

<td  align="left" style="padding: 0mm">
							<div align="left" style="padding-left: 20px;">
								<img src="', $member['online']['image_href'], '" alt="', $member['online']['link'], '" /> <span class="smalltext">', $member['link'],
						$xboxonline = $json['response'][0]['user']['is_online'],
						$xboxonline_status = $json['response'][0]['user']['online_status'], '</span><br />';

 

but i cant get json part to show the data for all the users

Link to comment
https://forums.phpfreaks.com/topic/242547-call-json-to-array/#findComment-1245825
Share on other sites

not sure

if i change the line

$gamertag =  $member['gamername'];

to

$gamertag =  'real gamer tag';

i do get a output but its the same for whole list, i have checked that  $member['gamername'] is showing the right gamer tag for the user, but if i use it i get nothing

 

been on this for to many hours just cant work it out

Link to comment
https://forums.phpfreaks.com/topic/242547-call-json-to-array/#findComment-1245840
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.