什么是 REST API POST 对炼金术的呼吁



我目前正在尝试从炼金术中发布并获取 JSON,我已经得到了,无论如何,我无法发布,有谁知道从 android 应用程序中的编辑文本中 psot 到炼金术的正确格式?有谁知道,我真的需要知道帖子的电话是什么?

public class MainActivity extends AppCompatActivity {

private VolleySingleton mVolleySingleton;
private RequestQueue mRequestQueue;
private RequestQueue mrequestQueue;
private static final String URL_GET="URL";;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Context getContext=(MainActivity.this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    Button SunnyButton = (Button) findViewById(R.id.PostButton);
    setSupportActionBar(toolbar);
    mVolleySingleton = VolleySingleton.getInstance();
    mRequestQueue = mVolleySingleton.getRequestQueue();
    JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, URL_GET, (String) null, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
          System.out.println(response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            error.printStackTrace();
        }
    });
    mRequestQueue.add(request);
}




@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}
public void ClickMe(View view) {
    final EditText editMe=(EditText)findViewById(R.id.EditText);
    String readText = editMe.getText() + " ";
    if (readText.length() == 1) {
        Toast toast = Toast.makeText(getApplicationContext(),
                "Please Enter Text", Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL, 0, 0);
        toast.show();
        return;
    }
    mVolleySingleton = VolleySingleton.getInstance();
    mrequestQueue = mVolleySingleton.getRequestQueue();
    JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, URL_GET, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            System.out.println(response + "reponse");
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            error.printStackTrace();
            System.out.println("************" + error + "error");
        }
    })
    {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            Map<String, String> parameters = new HashMap<String, String>();
            parameters.put("text", editMe.getText().toString());
            System.out.println(parameters + "parameters");
            return parameters;
        }
    };
    System.out.println("request " + request);
    mrequestQueue.add(request);
}

}

这取决于你在Alchemy上发布什么,以及你想做什么。 您可能应该查看并熟悉 Alchemy API 文档 (http://www.alchemyapi.com/api/calling-the-api(。 确保您拥有 Alchemy API 密钥,并且您了解特定计费计划施加的调用限制。

相关内容

  • 没有找到相关文章

最新更新