JSON (Converted to Array) データを PHP から ActionScript 3.0 に渡すときに問題が発生しました。
これが私のphpコードです:
class myTwitterOAuth {
public function get_user($username) {
$oauth = new TwitterOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret);
$param = array('screen_name'=>'twitter');
$data = $oauth->get('users/show', $param);
$json = json_encode($data);
$JSONarray=json_decode($json, true);
return $JSONarray; //To pass the whole Array not working
}
}
次に、アクション スクリプト メソッドについて説明します。
function whenSuccess(res:Object):void{
trace(res['name']); //Not working at all Neither name nor screen_name or any
}
Adobe Flash からのエラー:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at AS3PHPTesting01_fla::MainTimeline/whenSuccess()
アップデート
PHP と Action Script 間の通信に Amfphp ライブラリを使用しています。これが私がやっている方法です:
var gateway:String = "http://website/here/Amfphp/index.php";
var connection:NetConnection = new NetConnection();
connection.addEventListener(NetStatusEvent.NET_STATUS, errorConnection);
var res:Responder = new Responder(whenSuccess, whenFail);
connection.connect(gateway);
connection.call('myTwitterOAuth/get_user', res, param);