I want to pass some parameters to a php script sitting on a webserver. The url is http://tom.byethost3.com/gcmapp/gcm.php?shareRegId=true. On the php script side, it is supposed to detect with GET that shareRegId is not null and then gather the other information via POST.A text file will then be generated. I have tested this with my MAMP server and it works. However, whenever I execute this from the app, nothing happens, I still am successful in contacting the GCM server and getting a registration ID but I can't seem to trigger the url at all.
This is the script
//Get Reg ID sent from Android App and store it in text file
if(!empty($_GET["shareRegId"])) {
//$gcmRegID = $_GET["shareRegId"];
$gcmRegID = $_POST["regID"];
//echo $gcmRegID;
file_put_contents("./gcmtest/GCMRegId.txt",$gcmRegID);
echo "Done!";
exit;
}
This is how I send my request to the url
private void storeREG(){
pg.show();
params.put("regID", registerID);
Log.d("STORE","STORE");
//Make RESTful webservice call
AsyncHttpClient client = new AsyncHttpClient();
client.post(AppConstants.SERVER_URL,params,new AsyncHttpResponseHandler(){
@Override
public void onSuccess(String content) {
pg.hide();
if(pg!=null){
pg.dismiss();
}
Toast.makeText(applicationCtx,"ID sharing successful",Toast.LENGTH_LONG).show();
Intent home = new Intent(applicationCtx,HomeActivity.class);
home.putExtra("regID",registerID);
Log.d("REGID",registerID);
startActivity(home);
finish();
}
@Override
public void onFailure(int statusCode, Throwable error, String content) {
pg.hide();
if(pg!=null){
pg.dismiss();
}
Log.d("ERRORTHROW",error.toString());
if(statusCode==404){
Toast.makeText(applicationCtx,"Requested resource not found",Toast.LENGTH_LONG).show();
}else if(statusCode==500){
Toast.makeText(applicationCtx,"Something went wrong at the server",Toast.LENGTH_LONG).show();
}else{
Log.d("SHOWME",String.valueOf(statusCode));
Toast.makeText(applicationCtx,"Unexpected error occurred",Toast.LENGTH_LONG).show();
}
}
});
}
