Jump to content

Hello I need help with getting this url value into the foreach without the var dump because it causes a big loading time


Recommended Posts

 

<?php
$url = "https://api2.prices.tf/prices/".$datas["def_index"]."%3B".$datas["quality"];
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
   "accept: application/json",
   "Authorization: Bearer " .$value. " ",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);

foreach ($inventories['rgDescriptions'] as $key => $description) {
            $samik = $description['app_data'];
            echo $datas["def_index"]."<br>";
            echo $datas["quality"];    
    $unusual = $description['name_color'];
    if($unusual === "8650AC"){
        //do something with it
        $icon_url = $description['icon_url'];
        
        //$count = count($description['descriptions']);
        foreach ($description['descriptions'] as $key => $effects) {
            $effectsValue = $effects['value'];
            if (strpos($effectsValue, '★ Unusual Effect') !== false) {
                $effectValue = $effects['value'];
                //$effectColor = $effects['color'];
            }
            /*
            if (str_contains($effectsValue, '★ Unusual Effect')) { 
                $effectValue = $effects['value'];
                $effectColor = $effects['color'];
            }
            */
        }
        //$effectValue = $description['descriptions'][1]['value'];
        //$effectColor = $description['descriptions'][1]['color'];
        echo $effectValue;
        //echo $effectColor;

        echo '        
        <div class="item">      
            <img src="http://cdn.steamcommunity.com/economy/image/' . $icon_url . '/100fx60f" /> 
            <br />      
            ' . $description['market_name'] . '    
        </div> ';
    }else{
    $description['appid']; $description['market_name']; $icon_url = $description['icon_url'];echo '        <div class="item">      <img src="http://cdn.steamcommunity.com/economy/image/' . $icon_url . '/100fx60f" /> <br />      ' . $description['market_name'] . '    </div> ';

}
?>

Quote

Hello I need help with getting this url value into the foreach without the var dump because it causes a big loading time

That would be a great description for someone who was already familiar with everything you were doing and was watching over your shoulder as you tried to tackle this problem. We are neither.

  • Haha 1

foreach ($inventories['rgDescriptions'] as $key => $description){

$samik = $description['app_data'];

$url[] = "https://api2.prices.tf/prices/".$samik["def_index"]."%3B".$samik["quality"];

}

$curl = curl_init($url);curl_setopt($curl, CURLOPT_URL, $url);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array( "accept: application/json", "Authorization: Bearer " .$value. " ",);

curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

//for debug only!curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);curl_close($curl); //var_dump($resp);

I need foreach for the url and then use the data outside of the foreach in curl

 

Edited by samcadek

People will need to see the structure of $resp in order to help you.

Also, please use the code button <> to paste your code into your posts.

"{"sku":"730;6","buyHalfScrap":1,"buyKeys":0,"buyKeyHalfScrap":1238,"sellHalfScrap":2,"sellKeys":0,"sellKeyHalfScrap":1240,"createdAt":"2021-10-12T00:51:43.597Z","updatedAt":"2022-04-04T19:01:57.111Z"}" 

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.