I am currently working on Roblox API. I am stuck on one question. Reason : I have this link https://avatar.roblox.com/v1/users/2/currently-wearing. This shows what specified users have equipped on them. this link right here shows this: {“assetIds”:[382537569,607702162,607785314]} My goal is to get the assetIds to string. I tried this:
JavaScript
x
<?php
$id = 2;
$ch = file_get_contents("https://avatar.roblox.com/v1/users/$id/currently-wearing");
$ch = curl_init($ch);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
$data = json_decode($data);
$id = "$data->assetIds";
echo $id;
But it Shows Array. I need some help.
Advertisement
Answer
The cURL is not necessary as the file_get_contents()
get you the data you appear to require
JavaScript
$id = 2;
$ch = file_get_contents("https://avatar.roblox.com/v1/users/2/currently-wearing");
$data = json_decode($ch);
foreach ($data->assetIds as $id){
echo $id . PHP_EOL;
}
RESULT
JavaScript
382537569
607702162
607785314