我已经在我的域上安装了WP REST API插件。当我发送GET请求以从Web浏览器发布我的网站时,它会在HTML上显示一堆(http://honeymarket.org/wp-json/wp/v2/posts)。现在我如何从我的应用程序发送此请求?对于这个愚蠢的问题很抱歉,但谷歌出现了问题。
另外,如何从我的GET请求中获取数据,以便在我的应用中显示为帖子而不是HTML?
答案 0 :(得分:0)
import java.lang.invoke.*;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.reflect.Field;
import java.util.function.BiFunction;
public class Test {
public static void main(String[] args) throws Throwable {
// Reflectively generate a TRUSTED Lookup for the String class
Lookup caller = MethodHandles.lookup().in(String.class);
Field modes = Lookup.class.getDeclaredField("allowedModes");
modes.setAccessible(true);
modes.setInt(caller, -1); // -1 == Lookup.TRUSTED
// create handle for shared String constructor
MethodHandle constructor = caller.findConstructor(
String.class, MethodType.methodType(void.class, char[].class, boolean.class)
);
// generate interface implementation for constructor
BiFunction<char[],Boolean,String> shared=getStringCreator(caller, constructor);
// test if the construcor is correctly accessed
char[] chars = "foo".toCharArray();
String s = shared.apply(chars, true);
chars[0] = 'b'; chars[1] = 'a'; chars[2] = 'r';// modify array contents
System.out.println(s); // prints "bar"
chars[0] = '1'; chars[1] = '2'; chars[2] = '3';
System.out.println(s); // prints "123"
}
private static BiFunction<char[],Boolean,String> getStringCreator(
Lookup caller, MethodHandle handle) throws Throwable {
CallSite callSite = LambdaMetafactory.metafactory(
caller,
"apply",
MethodType.methodType(BiFunction.class),
handle.type().generic(),
handle,
handle.type()
);
return (BiFunction) callSite.getTarget().invokeExact();
}
}
中调用网络服务?如果您正在寻找此代码,请浏览此=&gt; How to Get Web-Service Call using java Code
<type>Error</type>
<source>Extension Manager</source>
<description>Error loading extension: This VSIX does not apply to any product installed on this machine. The problem could be that the VSIX manifest's format is not recognized, or that the manifest has been corrupted. Data at the root level is invalid. Line 1, position 1. </description>
<path>C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\MICROSOFT\VSGRAPHICS\</path>