ccmehil posted to #devku:

ccmehil

anyone have a good example of php reading Jaiku json stream? I get a weird "2ah22" in front of for example ['url'] value

1 year, 9 months ago.

11 comments so far

  • ccmehil

    actually it looks like I am getting back 2 a h 2 2 as individual values for the stream (only 2 comments in the stream)

    1 year, 9 months ago by ccmehil

  • RickMeasham

    There are two PHP libraries on this page

    1 year, 9 months ago by RickMeasham

  • ccmehil

    found those but the first link is dead (empty page) and the second I was just looking at

    1 year, 9 months ago by ccmehil

  • RickMeasham

    the first is mine .. I'll have to check what's happened

    1 year, 9 months ago by RickMeasham

  • ccmehil

    the eocond seems to only use json for the send of presence and xml for the receive, I'm trying http://jaiku.com/channel/devku/presence/25188504/json (xml does not work gives a weird return)

    1 year, 9 months ago by ccmehil

  • ccmehil

    ahh cool I will check back right now I gotta get some sleep it's 1am

    1 year, 9 months ago by ccmehil

  • dank

    I have a Drupal module that I rote that may be of some use to you (at least to see how PHP reads the JSON stream)

    1 year, 9 months ago by dank

  • ccmehil

    thanks but perhaps it something on the specific stream becasue that's they way I was trying to do it.

    $datac being response from curl for http://jaiku.com/channel/devku/presence/25188504/json

    $jsonStr = json_decode($datac, true);

                foreach ($jsonStr as $jEntry) {
                  echo "<br>url: ".$jEntry['url'];
                  echo "<br>nick: ".$jEntry['nick'];
                  echo "<br>content: ".$jEntry['content'];
                  echo "<br>date: ".$jEntry['created_at'];
                }
    

    1 year, 9 months ago by ccmehil

  • ccmehil

    I even tried $jEntry['user']['nick'] but nothing seems to work and I get like 5 entries of "dead" data before I get the main stream info it nevers seems to jump into the individual comment entries, so I'm thinking it's something super easy I am missing but I can't seem to see it at the moment.

    1 year, 9 months ago by ccmehil

  • ccmehil

    doh!

    echo $jsonStr['comments'][0]['url'];

    where 0 is the record id - I knew it must be something silly I was missing! thanks, anywhere I could put a small code sample for others?

    1 year, 9 months ago by ccmehil

  • dank

    You could put something in a pastebin

    1 year, 9 months ago by dank

Sign in to add a comment