duanjumie8753
duanjumie8753
2012-06-12 06:47

从iOS调用php函数

I am using the ASIHTTPREQUEST library and successfully posting data to a php script.

I do however have a single script holding related functions and I would like to call these functions from iOS.

Is this possible? if so is it a good way to do this or should one use isset($_POST['blah']) for the argument and another isset and pass in the function name?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dongxie548548 dongxie548548 9年前

    Yes, you can simply use POST or GET when you call the script if this script runs on a different server. You could try to use the way subscribed on this page:

    ASIHTTPRequest post json to php server

    You could post an array with index 'action' where you can wrap an Switch-case over.

    $action = isset( $_POST['action'] )? $_POST['action']: false;
    
    switch( $action ) {
        case 'function':
            // Do your thing
          break;
        default:
            // Unknow call
          break;
    }
    
    点赞 评论 复制链接分享

为你推荐