jacquagnui / php-twitter

Automatically exported from code.google.com/p/php-twitter
0 stars 0 forks source link

json_decode typecase error #6

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. use this code;
$t = new Twitter();
$t->username='un';          
$t->password='pw';
$r = $t->userTimeline(false, 1);
print_r($r);
2. try and access any of object properties... they all have a property name 
that is a number so you can't

What is the expected output? What do you see instead?
expected an array, got an object

What version of the product are you using? On what operating system?
1.0beta, linux, PHP 5.2.6

Please provide any additional information below.
Line 466 reads "return (object) json_decode( $data );"
if the JSON is an array it returns an array! You then turn it into an 
object and this makes no sense... there is no need for typecasting here.

if its an object the result ($r as above) would need to be accessed like 
this;

print_r($r->1);

but thats impossible.

if you take out "(object)" the following code then works fine.

print_r($r[0]);

Original issue reported on code.google.com by douga...@gmail.com on 20 Oct 2008 at 9:03

GoogleCodeExporter commented 8 years ago
Fixed in r65

Original comment by emmenset...@gmail.com on 28 Feb 2009 at 1:22