NetworkUtility.shouldRetryException: Unexpected response code 403 - php

excuse me, for the first it works fine, when I click "Tambah data/add data" its force close all of sudden, when I check on logcat it's showing this
NetworkUtility.shouldRetryException: Unexpected response code 403 for http://10.0.2.3/folder_kerja/koneksi.php
koneksi.php was made on separate file, I was trying to connect through MySQL.
could you help me please?
Here's the code
package com.example.a2011500069_dwizahranf2
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.*
import com.android.volley.*
import com.android.volley.toolbox.*
import java.net.*
import androidx.recyclerview.widget.*
import org.json.*
class MainActivity : AppCompatActivity() {
private lateinit var url: String
private lateinit var sr: StringRequest
private lateinit var rq: RequestQueue
private lateinit var rvAlumni: RecyclerView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
title = "E-Book Alumni Universitas XYZ"
rvAlumni = findViewById(R.id.rvAlumni)
val btnTambah = findViewById<Button>(R.id.btnTambah)
rvAlumni.setHasFixedSize(true)
rvAlumni.layoutManager = LinearLayoutManager(this#MainActivity)
btnTambah.setOnClickListener {
startActivity(Intent(this#MainActivity, EntriAlumniActivity::class.java))
}
}
private fun getDefaultGateway(): String? {
var defaultGateway: String? = null
try {
val enumNetworkInterface = NetworkInterface.getNetworkInterfaces()
while(enumNetworkInterface.hasMoreElements()) {
val networkInterface = enumNetworkInterface.nextElement()
val enumInetAddress = networkInterface.inetAddresses
while(enumInetAddress.hasMoreElements()) {
val inetAddress = enumInetAddress.nextElement()
if(inetAddress.isSiteLocalAddress) defaultGateway = inetAddress.hostAddress
}
}
} catch (_: SocketException) {
defaultGateway = null
}
return defaultGateway
}
override fun onStart() {
super.onStart()
val ipSebelumnya = ip
if (getDefaultGateway() != null) {
try {
for (i in 0..255) {
val kepalaIp =
getDefaultGateway()?.substring(0, getDefaultGateway()?.lastIndexOf(".") ?: -1)
val ipTemp = "$kepalaIp.$i"
url = "http://$ipTemp/folder_kerja/koneksi.php"
sr = StringRequest(Request.Method.GET, url, {
if (it.isNotEmpty()) {
ip = ipTemp
if(ip != ipSebelumnya) {
Toast.makeText(
this#MainActivity,
"Terhubung ke $ip",
Toast.LENGTH_SHORT
).show()
}
}
}, null)
rq = Volley.newRequestQueue(this#MainActivity)
rq.add(sr)
}
} catch (_: Exception) {
ip = "10.0.2.2"
}
} else ip = "10.0.2.2"
tampilData()
}
override fun onResume(){
super.onResume()
tampilData()
}
private fun tampilData(){
val listAlumni = arrayListOf<Alumni>()
val adapter = AdapterAlumni(listAlumni, this#MainActivity)
url = "http://$ip/folder_kerja/tampil.php"
sr = StringRequest(Request.Method.GET, url, {
try {
val obj = JSONObject(it)
val array = obj.getJSONArray("data")
for(i in 0 until array.length()) {
val ob = array.getJSONObject(i)
with(ob) {
listAlumni.add(
Alumni(
getString("nim"),
getString("nm_alumni"),
getString("prodi"),
getString("tmpt_lahir"),
getString("tgl_lahir"),
getString("alamat"),
getString("no_hp"),
getInt("thn_lulus")
)
)
}
}
rvAlumni.adapter = adapter
} catch(_: JSONException) {
Toast.makeText(this#MainActivity, "Tidak ada data...", Toast.LENGTH_LONG).show()
}
}, null)
rq = Volley.newRequestQueue(this#MainActivity)
rq.add(sr)
}
}
and this koneksi.php
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
I've no idea what should I change, try to remove the url the result was same, changing the IP but theres no change

Related

How to perform a WEBRTC peer to peer connection with id base for different tab?

I am new to work on WEBRTC I have tried to Implement simple peer connection
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="WebRTC code samples">
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1, maximum-scale=1">
</head>
<body>
<div id="container">
<video id="localVideo" playsinline autoplay muted></video>
<video id="remoteVideo" playsinline autoplay></video>
<div class="box">
<button id="startButton">Start</button>
<button id="callButton">Call</button>
<button id="hangupButton">Hang Up</button>
</div>
</div>
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
<script type="text/javascript">
'use strict';
const startButton = document.getElementById('startButton');
const callButton = document.getElementById('callButton');
const hangupButton = document.getElementById('hangupButton');
callButton.disabled = true;
hangupButton.disabled = true;
startButton.addEventListener('click', start);
callButton.addEventListener('click', call);
hangupButton.addEventListener('click', hangup);
let startTime;
const localVideo = document.getElementById('localVideo');
const remoteVideo = document.getElementById('remoteVideo');
localVideo.addEventListener('loadedmetadata', function() {
console.log(`Local video videoWidth: ${this.videoWidth}px, videoHeight: ${this.videoHeight}px`);
});
remoteVideo.addEventListener('loadedmetadata', function() {
console.log(`Remote video videoWidth: ${this.videoWidth}px, videoHeight: ${this.videoHeight}px`);
});
remoteVideo.addEventListener('resize', () => {
console.log(`Remote video size changed to ${remoteVideo.videoWidth}x${remoteVideo.videoHeight}`);
// We'll use the first onsize callback as an indication that video has started
// playing out.
if (startTime) {
const elapsedTime = window.performance.now() - startTime;
console.log('Setup time: ' + elapsedTime.toFixed(3) + 'ms');
startTime = null;
}
});
let localStream;
let pc1;
let pc2;
const offerOptions = {
offerToReceiveAudio: 1,
offerToReceiveVideo: 1
};
function getName(pc) {
return (pc === pc1) ? 'pc1' : 'pc2';
}
function getOtherPc(pc) {
return (pc === pc1) ? pc2 : pc1;
}
async function start() {
console.log('Requesting local stream');
startButton.disabled = true;
try {
const stream = await navigator.mediaDevices.getUserMedia({audio: true, video: true});
console.log('Received local stream');
localVideo.srcObject = stream;
localStream = stream;
callButton.disabled = false;
} catch (e) {
alert(`getUserMedia() error: ${e.name}`);
}
}
function getSelectedSdpSemantics() {
const sdpSemanticsSelect = document.querySelector('#sdpSemantics');
const option = sdpSemanticsSelect.options[sdpSemanticsSelect.selectedIndex];
return option.value === '' ? {} : {sdpSemantics: option.value};
}
async function call() {
callButton.disabled = true;
hangupButton.disabled = false;
console.log('Starting call');
startTime = window.performance.now();
const videoTracks = localStream.getVideoTracks();
const audioTracks = localStream.getAudioTracks();
if (videoTracks.length > 0) {
console.log(`Using video device: ${videoTracks[0].label}`);
}
if (audioTracks.length > 0) {
console.log(`Using audio device: ${audioTracks[0].label}`);
}
const configuration = getSelectedSdpSemantics();
console.log('RTCPeerConnection configuration:', configuration);
pc1 = new RTCPeerConnection(configuration);
console.log('Created local peer connection object pc1');
pc1.addEventListener('icecandidate', e => onIceCandidate(pc1, e));
pc2 = new RTCPeerConnection(configuration);
console.log('Created remote peer connection object pc2');
pc2.addEventListener('icecandidate', e => onIceCandidate(pc2, e));
pc1.addEventListener('iceconnectionstatechange', e => onIceStateChange(pc1, e));
pc2.addEventListener('iceconnectionstatechange', e => onIceStateChange(pc2, e));
pc2.addEventListener('track', gotRemoteStream);
localStream.getTracks().forEach(track => pc1.addTrack(track, localStream));
console.log('Added local stream to pc1');
try {
console.log('pc1 createOffer start');
const offer = await pc1.createOffer(offerOptions);
await onCreateOfferSuccess(offer);
} catch (e) {
onCreateSessionDescriptionError(e);
}
}
function onCreateSessionDescriptionError(error) {
console.log(`Failed to create session description: ${error.toString()}`);
}
async function onCreateOfferSuccess(desc) {
console.log(`Offer from pc1\n${desc.sdp}`);
console.log('pc1 setLocalDescription start');
try {
await pc1.setLocalDescription(desc);
onSetLocalSuccess(pc1);
} catch (e) {
onSetSessionDescriptionError();
}
console.log('pc2 setRemoteDescription start');
try {
await pc2.setRemoteDescription(desc);
onSetRemoteSuccess(pc2);
} catch (e) {
onSetSessionDescriptionError();
}
console.log('pc2 createAnswer start');
// Since the 'remote' side has no media stream we need
// to pass in the right constraints in order for it to
// accept the incoming offer of audio and video.
try {
const answer = await pc2.createAnswer();
await onCreateAnswerSuccess(answer);
} catch (e) {
onCreateSessionDescriptionError(e);
}
}
function onSetLocalSuccess(pc) {
console.log(`${getName(pc)} setLocalDescription complete`);
}
function onSetRemoteSuccess(pc) {
console.log(`${getName(pc)} setRemoteDescription complete`);
}
function onSetSessionDescriptionError(error) {
console.log(`Failed to set session description: ${error.toString()}`);
}
function gotRemoteStream(e) {
if (remoteVideo.srcObject !== e.streams[0]) {
remoteVideo.srcObject = e.streams[0];
console.log('pc2 received remote stream');
}
}
async function onCreateAnswerSuccess(desc) {
console.log(`Answer from pc2:\n${desc.sdp}`);
console.log('pc2 setLocalDescription start');
try {
await pc2.setLocalDescription(desc);
onSetLocalSuccess(pc2);
} catch (e) {
onSetSessionDescriptionError(e);
}
console.log('pc1 setRemoteDescription start');
try {
await pc1.setRemoteDescription(desc);
onSetRemoteSuccess(pc1);
} catch (e) {
onSetSessionDescriptionError(e);
}
}
async function onIceCandidate(pc, event) {
try {
await (getOtherPc(pc).addIceCandidate(event.candidate));
onAddIceCandidateSuccess(pc);
} catch (e) {
onAddIceCandidateError(pc, e);
}
console.log(`${getName(pc)} ICE candidate:\n${event.candidate ? event.candidate.candidate : '(null)'}`);
}
function onAddIceCandidateSuccess(pc) {
console.log(`${getName(pc)} addIceCandidate success`);
}
function onAddIceCandidateError(pc, error) {
console.log(`${getName(pc)} failed to add ICE Candidate: ${error.toString()}`);
}
function onIceStateChange(pc, event) {
if (pc) {
console.log(`${getName(pc)} ICE state: ${pc.iceConnectionState}`);
console.log('ICE state change event: ', event);
}
}
function hangup() {
console.log('Ending call');
pc1.close();
pc2.close();
pc1 = null;
pc2 = null;
hangupButton.disabled = true;
callButton.disabled = false;
}
</script>
</body>
</html>
I got above codes online which I have implemented but the connection is in the same tab,
how can I build a id base connection,
EG: creating rooms and other can join the room with id,
Any one can help me with this or can provide me a link where I can get idea to perform this in PHP

Laravel Webrtc video chat with react and pusher

I created a web app for video using Laravel, pusher and react js but now problem is that I was following the tutorial I don't know about the react but I'm good in Laravel.
Now I want to add a function where I can send email to a user so he can join me in video chat, right now it is working on click functions where react take an id and send the request to the client channel.
here is my react code.
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import MediaHandler from '../MediaHandler';
import Pusher from 'pusher-js';
import Peer from 'simple-peer';
const APP_KEY = 'removed-app-key';
export default class App extends Component {
constructor() {
super();
this.state = {
hasMedia: false,
otherUserId: null
};
this.user = window.user;
this.user.stream = null;
this.peers = {};
this.mediaHandler = new MediaHandler();
this.setupPusher();
this.callTo = this.callTo.bind(this);
this.setupPusher = this.setupPusher.bind(this);
this.startPeer = this.startPeer.bind(this);
}
componentWillMount() {
this.mediaHandler.getPermissions()
.then((stream) => {
this.setState({hasMedia: true});
this.user.stream = stream;
try {
this.myVideo.srcObject = stream;
} catch (e) {
this.myVideo.src = URL.createObjectURL(stream);
}
this.myVideo.play();
})
}
setupPusher() {
Pusher.logToConsole=true;
this.pusher = new Pusher(APP_KEY, {
authEndpoint: '/pusher/auth',
cluster: 'ap2',
auth: {
params: this.user.id,
headers: {
'X-CSRF-Token': window.csrfToken
}
}
});
this.channel = this.pusher.subscribe('presence-video-channel');
this.channel.bind(`client-signal-${this.user.id}`, (signal) => {
let peer = this.peers[signal.userId];
// if peer is not already exists, we got an incoming call
if(peer === undefined) {
this.setState({otherUserId: signal.userId});
peer = this.startPeer(signal.userId, false);
}
peer.signal(signal.data);
});
}
startPeer(userId, initiator = true) {
const peer = new Peer({
initiator,
stream: this.user.stream,
trickle: false
});
peer.on('signal', (data) => {
this.channel.trigger(`client-signal-${userId}`, {
type: 'signal',
userId: this.user.id,
userName:this.user.name,
data: data
});
});
peer.on('stream', (stream) => {
try {
this.userVideo.srcObject = stream;
} catch (e) {
this.userVideo.src = URL.createObjectURL(stream);
}
this.userVideo.play();
});
peer.on('close', () => {
let peer = this.peers[userId];
if(peer !== undefined) {
peer.destroy();
}
this.peers[userId] = undefined;
});
return peer;
}
callTo(userId) {
this.peers[userId] = this.startPeer(userId);
}
render() {
return (
<div className="App">
{[1,2,3,4].map((userId) => {
return this.user.id !== userId ? <button key={userId} onClick={() => this.callTo(userId)}>Call {name}</button> : null;
})}
<div className="video-container">
<video className="my-video" ref={(ref) => {this.myVideo = ref;}}></video>
<video className="user-video" ref={(ref) => {this.userVideo = ref;}}></video>
</div>
</div>
);
}
}
if (document.getElementById('app')) {
ReactDOM.render(<App />, document.getElementById('app'));
}
Here is my pusher function.
public function authenticate(Request $request){
$socketId= $request->socket_id;
$channelName= $request->channel_name;
$pusher = new Pusher('APP_KEY', 'APP_SECRET','APP_ID',['cluster'=> 'ap2','forceTLS'=>true]);
$presence_data = ['name' => auth()->user()->name];
$key = $pusher->presence_auth($channelName, $socketId, auth()->id(), $presence_data);
return response($key);
}
My head script
!-- Scripts -->
#if(auth()->user())
<script>
window.user = {
id:{{auth()->id()}},
name:"{{auth()->user()->first_name}}"
};
window.csrfToken = "{{ csrf_token() }}";
</script>
#endif
The simple thing I want to create a room where I can send email to user to join me one-to-one video chat.
I'm searching this from last night but no good result till now

Ionic fails to load data on device

I have test this ionic code on my browser, it works as expected
services.js
angular.module('starter.services', [])
.factory('Penjualan', function($http) {
var dataArray = $http.get('http://192.168.1.35/test.php');
return {
all: function() {
return dataArray;
},
remove: function(data) {
dataArray.splice(dataArray.indexOf(data), 1);
},
get: function(dataId) {
for (var i = 0; i < dataArray.length; i++) {
if (dataArray[i].sqlrecno === parseInt(dataId)) {
return dataArray[i];
}
}
return null;
}
};
});
This is the portion of the code inside 192.168.1.35/test.php
$dsn = 'mysql:dbname=test;host=192.168.1.35';
$user = 'xxx';
$password = 'xxx';
My php file returns json which will be used in my ionic project. 192.168.1.35 is my computer ip. It works on my computer, but the app fails to load json data on device.

How to make client talk to server in same node proccess?

I have an application written in SSJS (Node) ... This application needs to serve data to the php script that will request by fsockopen .. All right here ... This server needs to collect data from a second server through a persistent connection. How to do this? Making the same process coordinate these connections? Is this possible?
var net = require('net');
/* #############################################
# "CLIENT" Used to connect to data server
# ---------------------------------
#############################################
*/
var clientConnect = net.createConnection(port, host);
clientConnect.setEncoding('utf8');
clientConnect.on('connect', function () {
console.log('Client','Connected to CAGEAPI');
clientConnect.write('user#pass');
});
clientConnectt.on('data', function (data) {
console.log('Client','Data received: ' + data);
});
clientConnect.on('close', function(code) {
console.log('Client','Connection closed');
});
clientConnect.on('error', function (err) {
console.log(err);
});
/* ################################################
#
# "SERVER" Used to serv data to PHPScripts
# --------------------------------
################################################
*/
var handleServer = net.createServer(function(server) {
console.log('Server','CONNECTED: ' + server.remoteAddress +':'+ server.remotePort);
server.on('data', function(data) {
console.log('Server','DATA ' + server.remoteAddress + ': ' + data);
// Write the data back to the socket, the client will receive it as data from the server
server.write('You said "' + data + '"');
});
// Add a 'close' event handler to this instance of socket
server.on('close', function(data) {
console.log('Server','CLOSED: ' + server.remoteAddress +' '+ server.remotePort);
});
}).listen(port2, host2);
Both (Client and server) is working fine... But how to make they talk each other?
I think you're probably after something like this:
/*jslint node: true, white: true */
// Declare constructors
var DataSource, PHPClientServer;
// The DataSource class
// Handles connecting/reconnecting to the data source, and piping endpoints together
(function() {
"use strict";
DataSource = function(net)
{
this.net = net;
};
DataSource.prototype.net = null;
DataSource.prototype.host = 'localhost';
DataSource.prototype.port = 0;
DataSource.prototype.user = '';
DataSource.prototype.pass = '';
DataSource.prototype.socket = null;
DataSource.prototype.currentClient = null;
DataSource.prototype.start = function(host, port, user, pass)
{
if (host !== undefined) {
this.host = host;
}
if (port !== undefined) {
this.port = port;
}
if (user !== undefined) {
this.user = user;
}
if (pass !== undefined) {
this.pass = pass;
}
this.socket = this.net.createConnection(this.port, this.host);
this.socket.on('connect', function () {
console.log('Data source connected');
this.socket.write(this.user + '#' + this.pass);
}.bind(this));
this.socket.on('error', function() {
console.error('Error on data source connection');
this.stop();
this.start();
}.bind(this));
this.socket.on('end', function() {
console.error('Data source connection terminated');
this.stop();
this.start();
}.bind(this));
};
DataSource.prototype.stop = function()
{
this.socket.end();
this.socket = null;
};
DataSource.prototype.attachClient = function(client)
{
console.log('Attaching client to data source');
this.currentClient = client;
this.socket.pipe(this.currentClient);
this.currentClient.pipe(this.socket, {end: false});
};
DataSource.prototype.detachCurrentClient = function()
{
console.log('Detaching client from data source');
this.socket.unpipe(this.currentClient);
this.currentClient.unpipe(this.socket);
this.currentClient = null;
};
DataSource.prototype.hasClient = function()
{
return this.currentClient !== null;
};
}());
// The PHPClientServer class
// Handles the server operations for PHP clients
(function() {
"use strict";
PHPClientServer = function(net, dataSource)
{
this.net = net;
this.dataSource = dataSource;
this.pendingClientStack = [];
};
PHPClientServer.prototype.net = null;
PHPClientServer.prototype.dataSource = null;
PHPClientServer.prototype.host = null;
PHPClientServer.prototype.port = null;
PHPClientServer.prototype.server = null;
PHPClientServer.prototype.pendingClientStack = null;
PHPClientServer.prototype.start = function(host, port)
{
var clientTerminateHandler = function() {
console.log('Client disconnected');
this.dataSource.detachCurrentClient();
if (this.pendingClientStack.length) {
console.log('Attaching next client in queue');
this.dataSource.attachClient(this.pendingClientStack.shift());
}
}.bind(this);
if (host !== undefined) {
this.host = host;
}
if (port !== undefined) {
this.port = port;
}
this.server = this.net.createServer(function(client) {
console.log('Client connected');
client.on('end', clientTerminateHandler);
client.on('error', clientTerminateHandler);
if (this.dataSource.hasClient()) {
console.log('Client added to queue');
this.pendingClientStack.push(client);
} else {
this.dataSource.attachClient(client);
}
}.bind(this));
this.server.listen(this.port, this.host);
};
PHPClientServer.prototype.stop = function()
{
this.server.close();
this.server = null;
};
}());
// Bootstrap
var net, dataSource, server;
net = require('net');
dataSource = new DataSource(net);
dataSource.start('192.168.0.1', 23);
server = new PHPClientServer(net, dataSource);
server.start('0.0.0.0', 12345);
I realise that's a wall of code with minimal explanation, so please ask if there's something you don't understand.
Also, before anyone says it, yes I am fully aware that I am treating a prototypical OOP language as if it were a classical one, Javascript != Java, yada yada yada. I don't care, I like to work with Javascript in this manner.

Load JSON data with URL loader

I am new to action script 3.0. Help me to understand how can I load data with URLLoader.
So, I have an aplication like:
var PATH:String = "http://www.somesite.com/myFirstPage.php?a=10&b=20";
var urlRequest:URLRequest = new URLRequest(PATH);
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
urlLoader.addEventListener(Event.COMPLETE, urlLoader_complete);
urlLoader.load(urlRequest);
function urlLoader_complete(evt:Event):void {
some_result = urlLoader.data;
}
php script looks like:
<?php
//retrieve GET params
int c = a + b; //a and b come from GET request
return "{{"result_equal":"20"}}"; //result in JSON
?>
I don't really understand how JSON result from .php page gets in my URLLoader object. Help me by simple example, please. Thanx!
You need a few things here. First off, you'll need a JSON library, because somehow it isn't built into Flash, even with their modified E4X core:
https://github.com/mikechambers/as3corelib
This should give you the following bits of code:
import com.adobe.serialization.json.JSON;
function urlLoader_complete(e:Event):void
{
var loader:URLLoader = URLLoader(e.target);
var some_result:Object = JSON.decode(loader.data);
}
Now... your PHP code is a mess. The best way to create JSON is to just use the json_encode function:
$retVal = array('result_equal'=>20);
echo json_encode($retVal);
You will want to use this project: https://github.com/mikechambers/as3corelib
Example usage:
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import com.adobe.serialization.json.JSON;
private function onJSONLoad(event:ResultEvent):void
{
var rawData:String = String(event.result);
var arr:Array = (JSON.decode(rawData) as Array);
var dp:ArrayCollection = new ArrayCollection(arr);
grid.dataProvider = dp;
}
]]>
</mx:Script>
<mx:HTTPService
id="service"
resultFormat="text"
url="http://weblogs.macromedia.com/mesh/mashedpotato.json"
result="onJSONLoad(event)" />
PHP code should looks like this:
$result = array("result_equal" => 20);
return json_encode($result);
So, this is what I get: Please, say whats wrong, what good! Thanx1
package
{
import data.*;
import flash.errors.IOError;
import flash.events.Event;
import flash.events.*;
import flash.net.*;
public class UserInfoProxy
{
public static const GET_USER_INFO:DataCallConfigVO = new DataCallConfigVO( "COMMON", 'GET_USER_INFO', true, null, null);
public function UserInfoProxy()
{
trace("Start request");
var request:URLRequest = new URLRequest("http://www.avrora.com.localhost/myservlet.php");
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.load(request);
}
private function completeHandler(event:Event):void
{
var loader:URLLoader = URLLoader(event.target);
trace("Complete");
trace("completeHandler: " + loader.data);
}
private function progressHandler(event:ProgressEvent):void
{
trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
}
private function securityErrorHandler(event:SecurityErrorEvent):void
{
trace("securityErrorHandler: " + event);
}
private function httpStatusHandler(event:HTTPStatusEvent):void
{
trace("httpStatusHandler: " + event);
}
private function ioErrorHandler(event:IOErrorEvent):void
{
trace("ioErrorHandler: " + event);
}
}
}
And this is my PHP code, that must return JSON data:
<?
//here I can process all input GET, POST params, database etc...
$someJSONresponse = "{'username':'yozhik', 'age':'18'}";
//here just echo result and it will be automatically downloaded??
echo $someJSONresponse;
?>

Categories