0

I got a new problem while working on my project.

I want to decode this (what I tried until now):

$items = array($_POST['eingabe']);      
$strs = file_get_contents("https://open-market.io/api/search/?name=$items&appID=730&limit=5");
$json = json_decode($strs, true);
$picimage = $json['results'][0]['image'];
echo '<a class="test1">' . $picimage . '</a></div></br>';

I really don't know what I did wrong. Can someone please show me my mistake?

example for json:

https://open-market.io/api/search/?name=Chroma%20Case&appID=730&limit=5

Nassim
  • 2,879
  • 2
  • 37
  • 39
ideasia
  • 3
  • 6
  • What is in your request url? can you echo "https://open-market.io/api/search/?name=$items&appID=730&limit=5" – kurt Dec 21 '15 at 22:44
  • For example: https://open-market.io/api/search/?name=Chroma%20Case&appID=730&limit=5 – ideasia Dec 21 '15 at 22:46
  • your code works fine on myside, I used "counter" as the name param. You need to look at whats in $items. FYI, you should remove your appID be careful about posting confidential info. – kurt Dec 21 '15 at 22:51
  • Thats not a confidential info :) it's the appID of Counter Strike Global Offensive .... so I think it dont matter. – ideasia Dec 21 '15 at 22:54
  • cool just checking ;), posted an answer that solves your problem its because your referencing an array as a string. – kurt Dec 21 '15 at 22:58
  • the base64 of image is invalid ? (tried few mime type, but nothing) – MTroy Dec 21 '15 at 23:01

1 Answers1

0

implode your array and urlencode it.

<?php
$items = array('counter','age');
$strs = file_get_contents("https://open-market.io/api/search/?name=".urlencode(implode($items,','))."&appID=730&limit=5");
$json = json_decode($strs, true);
$picimage = $json['results'][0]['image'];
echo '<a class="test1"> ' . $picimage . "</a></div></br>";
kurt
  • 1,146
  • 1
  • 8
  • 18