- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在 PayPal 网站上,所有示例调用都是使用 curl 完成的。在 Linux 下使用 CURL 很容易重复,但我想使用 Java 进行这些调用。
例如,假设有电话:
curl -v https://api.sandbox.paypal.com/v1/payments/payment \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <Access-Token>' \
-d '{
"intent":"sale",
"redirect_urls":{
"return_url":"http://example.com/your_redirect_url.html",
"cancel_url":"http://example.com/your_cancel_url.html"
},
"payer":{
"payment_method":"paypal"
},
"transactions":[
{
"amount":{
"total":"7.47",
"currency":"USD"
}
}
]
}'
假设我有 <Access-Token>
的值必须设置,我如何将之前的字符串转换为 http 请求,以使用 Java 且不使用 CURL 从 PayPal 获得答案?
现在我对 URL 的 HttpURLConnection 做了如下操作:
private HttpURLConnection createPOSTHttpURLConnection(final URL url) throws IOException {
final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestProperty("User-Agent", "Mozilla/4.0");
return connection;
}
在我的主要我做如下:
final HttpURLConnection connection = createPOSTHttpURLConnection(url);
connection.setRequestProperty("Authorization", "Bearer <Access-Token>");//replaced with a real value
connection.setRequestProperty("Content-Type", "application/json");
final String jsonData = "{ \"intent\":\"sale\", \"redirect_urls\":{ \"return_url\":\"http://example.com/your_redirect_url.html\", \"cancel_url\":\"http://example.com/your_cancel_url.html\" }, \"payer\":{ \"payment_method\":\"paypal\" }, \"transactions\":[ { \"amount\":{ \"total\":\"7.47\", \"currency\":\"USD\"}}]}";
connection.setFixedLengthStreamingMode(jsonData.length());
// get the output stream to POST to.
try(final DataOutputStream output = new DataOutputStream(connection.getOutputStream())) {
output.writeBytes(jsonData);
output.flush();
}
final InputStream isToBeRead = connection.getInputStream();
但是,我收到以下错误:
Cannot read from the given URL https://api.sandbox.paypal.com/v1/payments/payment with given params and data
当我尝试使用 InputStream
时发生了 Tha :
java.net.HttpRetryException: cannot retry due to server authentication, in streaming mode
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1636)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at com.sudengut.de.utils.url.HttpClient.readFromHttpURL(HttpClient.java:65)
实现 Kevin Hoffman '解决方案我得到以下结果:
Server returned HTTP response code: 400 for URL: https://api.sandbox.paypal.com/v1/payments/payment
Response code:400
Response message:Bad Request
实现 Garry的回答我得到以下日志:
21:30:06.070 [main] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default
21:30:06.109 [main] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
21:30:06.111 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://api.sandbox.paypal.com:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
21:30:06.143 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {s}->https://api.sandbox.paypal.com:443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
21:30:06.147 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {s}->https://api.sandbox.paypal.com:443
21:30:06.202 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to api.sandbox.paypal.com/173.0.82.78:443
21:30:06.202 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Connecting socket to api.sandbox.paypal.com/173.0.82.78:443 with timeout 0
21:30:06.668 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2]
21:30:06.668 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, TLS_ECDHE_RSA_WITH_RC4_128_SHA, SSL_RSA_WITH_RC4_128_SHA, TLS_ECDH_ECDSA_WITH_RC4_128_SHA, TLS_ECDH_RSA_WITH_RC4_128_SHA, SSL_RSA_WITH_RC4_128_MD5, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
21:30:06.669 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Starting handshake
21:30:07.291 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Secure session established
21:30:07.291 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - negotiated protocol: TLSv1.2
21:30:07.292 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - negotiated cipher suite: TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
21:30:07.292 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - peer principal: CN=api.sandbox.paypal.com, OU=PayPal Production, O="PayPal, Inc.", L=San Jose, ST=California, C=US
21:30:07.292 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - peer alternative names: [api.sandbox.paypal.com]
21:30:07.293 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - issuer principal: CN=VeriSign Class 3 Secure Server CA - G3, OU=Terms of use at https://www.verisign.com/rpa (c)10, OU=VeriSign Trust Network, O="VeriSign, Inc.", C=US
21:30:07.306 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connection established 192.168.178.22:45213<->173.0.82.78:443
21:30:07.306 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request POST /v1/payments/payment HTTP/1.1
21:30:07.306 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
21:30:07.310 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> POST /v1/payments/payment HTTP/1.1
21:30:07.310 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Type: application/json
21:30:07.310 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Authorization: Bearer A015TlBaYzfyFSUt9rVin-Lnltn6JuQLA968RyGGC8h.Zds
21:30:07.310 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 254
21:30:07.311 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: api.sandbox.paypal.com
21:30:07.311 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
21:30:07.311 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5 (Java/1.8.0_25)
21:30:07.311 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate
21:30:07.311 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "POST /v1/payments/payment HTTP/1.1[\r][\n]"
21:30:07.311 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Type: application/json[\r][\n]"
21:30:07.311 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Authorization: Bearer A015TlBaYzfyFSUt9rVin-Lnltn6JuQLA968RyGGC8h.Zds[\r][\n]"
21:30:07.311 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Length: 254[\r][\n]"
21:30:07.311 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: api.sandbox.paypal.com[\r][\n]"
21:30:07.311 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
21:30:07.311 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5 (Java/1.8.0_25)[\r][\n]"
21:30:07.311 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
21:30:07.311 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"
21:30:07.312 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "{ "intent":"sale","redirect_urls":{ "return_url":"http://example.com/your_redirect_url.html", "cancel_url ":"http://example.com/your_cancel_url.html" }, "payer":{"payment_method":"paypal"},"transactions":[{ "amount":{ "total":"7.47", "currency":"USD"}}]}"
21:30:07.663 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 400 Bad Request[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Wed, 29 Jul 2015 19:30:07 GMT[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Server: Apache[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "PROXY_SERVER_INFO: host=slcsbplatformapiserv3001.slc.paypal.com;threadId=205[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Paypal-Debug-Id: 3780624b824ed[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "CORRELATION-ID: 3780624b824ed[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Language: *[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Connection: close[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Connection: close[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Length: 404[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D880%26app%3Dplatformapiserv%26TIME%3D3207182677; domain=.paypal.com; path=/; Secure; HttpOnly[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Vary: Authorization[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Type: application/json[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
21:30:07.664 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "{"name":"VALIDATION_ERROR","details":[{"field":"redirect_urls.cancel_url ","issue":"This field name is not defined for this resource type"},{"field":"redirect_urls.cancel_url","issue":"This field required when payment_method is 'paypal'"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"3780624b824ed"}"
21:30:07.669 [main] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 400 Bad Request
21:30:07.669 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Wed, 29 Jul 2015 19:30:07 GMT
21:30:07.669 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Server: Apache
21:30:07.669 [main] DEBUG org.apache.http.headers - http-outgoing-0 << PROXY_SERVER_INFO: host=slcsbplatformapiserv3001.slc.paypal.com;threadId=205
21:30:07.669 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Paypal-Debug-Id: 3780624b824ed
21:30:07.669 [main] DEBUG org.apache.http.headers - http-outgoing-0 << CORRELATION-ID: 3780624b824ed
21:30:07.669 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Language: *
21:30:07.669 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Connection: close
21:30:07.669 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Connection: close
21:30:07.669 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Length: 404
21:30:07.669 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D880%26app%3Dplatformapiserv%26TIME%3D3207182677; domain=.paypal.com; path=/; Secure; HttpOnly
21:30:07.669 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
21:30:07.669 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Vary: Authorization
21:30:07.669 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: application/json
21:30:07.681 [main] DEBUG o.a.h.c.p.ResponseProcessCookies - Cookie accepted [X-PP-SILOVER="name%3DSANDBOX3.API.1%26silo_version%3D880%26app%3Dplatformapiserv%26TIME%3D3207182677", version:0, domain:paypal.com, path:/, expiry:null]
21:30:07.684 [main] WARN o.a.h.c.p.ResponseProcessCookies - Invalid cookie header: "Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT". Invalid 'expires' attribute: Thu, 01 Jan 1970 00:00:01 GMT
如果我用更多信息来解决这个问题,我会看到给定的 cookie 已附加并且不会替换缺少到期日期的 cookie。只需运行:
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import org.apache.http.HttpResponse;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.cookie.BasicClientCookie;
import org.apache.http.protocol.HTTP;
public class GarrysSolution {
public static void main(final String[] args) {
String accessToken = "A-valid-token";
String jsonString =
"{ \"intent\":\"sale\",\"redirect_urls\":{ \"return_url\":\"http://example.com/your_redirect_url.html\", \"cancel_url \":\"http://example.com/your_cancel_url.html\" }, \"payer\":{\"payment_method\":\"paypal\"},\"transactions\":[{ \"amount\":{ \"total\":\"7.47\", \"currency\":\"USD\"}}]}";
BasicCookieStore cookieStore = new BasicCookieStore();
BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", "1234");
cookie.setDomain(".paypal.com");
cookie.setPath("/");
LocalDate expirationDate = LocalDate.now().plus(100L, ChronoUnit.DAYS);
Instant instant = Instant.from(expirationDate.atStartOfDay(ZoneId.of("GMT")));
cookie.setExpiryDate(Date.from(instant));
cookie.setCreationDate(Date.from(Instant.now()));
cookieStore.addCookie(cookie);
RequestConfig globalConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.NETSCAPE).build(); HttpClientContext context = HttpClientContext.create();
context.setCookieStore(cookieStore);
HttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(globalConfig)
.setDefaultCookieStore(cookieStore).build();
HttpPost httpPost = new HttpPost("https://api.sandbox.paypal.com/v1/payments/payment");
httpPost.setHeader("Content-Type", "application/json");
httpPost.setHeader("Authorization", "Bearer " + accessToken);
StringEntity entity = new StringEntity(jsonString, HTTP.UTF_8);
entity.setContentType("application/json");
httpPost.setEntity(entity);
try {
HttpResponse httpResponse = httpClient.execute(httpPost, context);
System.out.println("\n\n" + context.getCookieStore().getCookies());
System.out.println("\n\n" + httpResponse.getStatusLine().getStatusCode() + "/"
+ httpResponse.getStatusLine().getReasonPhrase());
} catch (Exception e) {
System.err.println(e.getMessage());
}
}
}
我们从上下文中看到以下 cookie:
[[version: 0][name: JSESSIONID][value: 1234][domain: .paypal.com][path: /][expiry: Fri Nov 06 01:00:00 CET 2015], [version: 0][name: X-PP-SILOVER][value: name%3DSANDBOX3.API.1%26silo_version%3D880%26app%3Dplatformapiserv%26TIME%3D2370156885][domain: .paypal.com][path: /][expiry: null]]
所以我想这个问题可以通过将到期日期设置为适当的 cookie 来解决
最佳答案
代码吞没了异常(在没有捕获的 try block 中),该异常被抛出以指示正在发生 HTTP 错误 401(未经授权)。这可能是由于访问 token 无效所致。然后代码尝试读取 HTTP 响应,但失败了(因为 401 错误导致没有响应)并抛出正在打印到屏幕上的异常。
是否有可能在您设置代码时访问 token 已过期?
我获得了以下代码(下方),可以使用有效的访问 token 成功地使用 PayPal。与您的代码有一些细微差别(没有单独的方法;使用 HttpsURLConnection 而不是 HttpUrlConnection;删除了一些不需要的 header ;等等),但是这些更改都没有使它单独工作——它们只是稍微收紧了它并确保了它出现问题时打印正确的错误消息。然后,一旦我提供了一个有效的访问 token ,它就成功运行了。我想你知道尖括号 < >
必须删除访问 token 周围的内容,否则您将永远不会获得 curl
工作方法。
此外,请记住这只是示例代码 - 生产代码应将关闭语句移动到 finally
中 block ,或者返回到您最初使用的尝试资源方法。
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.DataOutputStream;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
public class TestHttpsPost {
public static void main(String[] args) throws Exception {
// Uncomment one of these next two lines:
URL url = new URL("https://api.sandbox.paypal.com/v1/payments/payment");
//URL url = new URL("https://httpbin.org/post"); // good for testing
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setDoInput(true);
connection.setDoOutput(true);
// Change this to a valid token:
connection.setRequestProperty("Authorization", "Bearer <Access-Token>");
connection.setRequestProperty("Content-Type", "application/json");
String jsonData = "{ \"intent\":\"sale\", \"redirect_urls\":{ \"return_url\":\"http://example.com/your_redirect_url.html\", \"cancel_url \":\"http://example.com/your_cancel_url.html\" }, \"payer\":{ \"payment_method\":\"paypal\" }, \"transactions\":[ { \"amount\":{ \"total\":\"7.47\", \"currency\":\"USD\"}}]}";
try {
// Post the data:
DataOutputStream output = new DataOutputStream(connection.getOutputStream());
output.writeBytes(jsonData);
output.close();
// Read the response:
BufferedReader reader = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
reader.close();
} catch (Exception e) {
System.out.println(e.getMessage());
}
System.out.println("Response code:" + connection.getResponseCode());
System.out.println("Response message:" + connection.getResponseMessage());
}
}
关于java - 将 PayPal curl 请求转换为 Java 中的 http 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31627733/
我正在尝试将一个字符串逐个字符地复制到另一个字符串中。目的不是复制整个字符串,而是复制其中的一部分(我稍后会为此做一些条件......) 但我不知道如何使用迭代器。 你能帮帮我吗? std::stri
我想将 void 指针转换为结构引用。 结构的最小示例: #include "Interface.h" class Foo { public: Foo() : mAddress((uint
这有点烦人:我有一个 div,它从窗口的左上角开始过渡,即使它位于文档的其他任何位置。我试过 usign -webkit-transform-origin 但没有成功,也许我用错了。有人可以帮助我吗?
假设,如果将 CSS3 转换/转换/动画分配给 DOM 元素,我是否可以检测到该过程的状态? 我想这样做的原因是因为我正在寻找类似过渡链的东西,例如,在前一个过渡之后运行一个过渡。 最佳答案 我在 h
最近我遇到了“不稳定”屏幕,这很可能是由 CSS 转换引起的。事实上,它只发生在 Chrome 浏览器 上(可能还有 Safari,因为一些人也报告了它)。知道如何让它看起来光滑吗?此外,您可能会注意
我正在开发一个简单的 slider ,它使用 CSS 过渡来为幻灯片设置动画。我用一些基本样式和一些 javascript 创建了一支笔 here .注意:由于 Codepen 使用 Prefixfr
我正在使用以下代码返回 IList: public IList FindCodesByCountry(string country) { var query =
如何设计像这样的操作: 计算 转化 翻译 例如:从“EUR”转换为“CNY”金额“100”。 这是 /convert?from=EUR&to=CNY&amount=100 RESTful 吗? 最佳答
我使用 jquery 组合了一个图像滚动器,如下所示 function rotateImages(whichHolder, start) { var images = $('#' +which
如何使用 CSS (-moz-transform) 更改一个如下所示的 div: 最佳答案 你可以看看Mozilla Developer Center .甚至还有例子。 但是,在我看来,您的具体示例不
我需要帮助我正在尝试在选中和未选中的汉堡菜单上实现动画。我能够为菜单设置动画,但我不知道如何在转换为 0 时为左菜单动画设置动画 &__menu { transform: translateX(
我正在为字典格式之间的转换而苦苦挣扎:我正在尝试将下面的项目数组转换为下面的结果数组。本质上是通过在项目第一个元素中查找重复项,然后仅在第一个参数不同时才将文件添加到结果集中。 var items:[
如果我有两个定义相同的结构,那么在它们之间进行转换的最佳方式是什么? struct A { int i; float f; }; struct B { int i; float f; }; void
我编写了一个 javascript 代码,可以将视口(viewport)从一个链接滑动到另一个链接。基本上一切正常,你怎么能在那里看到http://jsfiddle.net/DruwJ/8/ 我现在的
我需要将文件上传到 meteor ,对其进行一些图像处理(必要时进行图像转换,从图像生成缩略图),然后将其存储在外部图像存储服务器(s3)中。这应该尽可能快。 您对 nodejs 图像处理库有什么建议
刚开始接触KDB+,有一些问题很难从Q for Mortals中得到。 说,这里 http://code.kx.com/wiki/JB:QforMortals2/casting_and_enumera
我在这里的一个项目中使用 JSF 1.2 和 IceFaces 1.8。 我有一个页面,它基本上是一大堆浮点数字段的大编辑网格。这是通过 inputText 实现的页面上的字段指向具有原始值的值对象
ScnMatrix4 是一个 4x4 矩阵。我的问题是什么矩阵行对应于位置(ScnVector3),旋转(ScnVector4),比例(ScnVector3)。第 4 行是空的吗? 编辑: 我玩弄了
恐怕我是 Scala 新手: 我正在尝试根据一些简单的逻辑将 Map 转换为新 Map: val postVals = Map("test" -> "testing1", "test2" -> "te
输入: This is sample 1 This is sample 2 输出: ~COLOR~[Green]This is sample 1~COLOR~[Red]This is sam
我是一名优秀的程序员,十分优秀!