我正在尝试使用WhatsApi官方库通过WhatsApp从php文件发送消息.我已经在我的Apache Web服务器中移动了库,在文件夹调用测试中,如下所示:
文件whatsapp.php就是这个:
<?php
require_once './src/whatsprot.class.php';
$username = "1XXXXXXXXX";
$password = "password";
$w = new WhatsProt($username, "0", "My Nickname", true); //Name your application by replacing “WhatsApp Messaging”
$w->connect();
$w->loginWithPassword($password);
$target = '1xxxxxxxxx'; //Target Phone,reciever phone
$message = 'This is my messagge';
$w->SendPresenceSubscription($target); //Let us first send presence to user
$w->sendMessage($target,$message ); // Send Message
echo "Message Sent Successfully";
?>
Run Code Online (Sandbox Code Playgroud)
库我新的WhatsProt()会遇到一些问题,它会阻塞所有代码(可能是套接字?).
所以我的问题是,我该如何解决这个问题呢?如果不是,还有其他解决方案从pho脚本发送消息吗?
我必须处理重构,以减少PHP中的代码行数,以过滤关联数组.所以我在MySQL中选择DB,以获得一个关联数组.所以我的"对象"有一个类别和一个姓氏字段.
while ($row = mysqli_fetch_array($result)) {
$array[] = $row['category'];
$array[] = $row['Surname'];
}
Run Code Online (Sandbox Code Playgroud)
我想从这个数组中获取,就像许多其他子数组一样,按类别划分.我的意思是类别数组标识可能是:
$categories = array("A","B","C","D");
Run Code Online (Sandbox Code Playgroud)
所以我想要的是为每个类别获取一个数组,其中包含该类别的所有姓氏.所以假设该方法有效,如下所示:
$arrayFiltered = method_filter($array_asso,"A");
Run Code Online (Sandbox Code Playgroud)
最后我想要这样的东西:
foreach ($categories as &$value) {
$arrayFiltered = method_filter($array_asso,$value);
my_method_which_needs_the_filtered_array($arrayFiltered);
}
Run Code Online (Sandbox Code Playgroud)
预先感谢您的帮助.
我用Eclipse开发了一个Java应用程序.我也以.jar
格式导出.它运作良好,但有一些问题;
所以最后,我想将.jar
文件转换为其他操作系统的本机格式,例如.exe
,.app
并.deb
使用特定的图标.我怎样才能做到这一点 ?
我想使用Volley Library将JSON文件从Android应用程序发送到REST API服务器.首先,我想用JUnit Tests测试库,看看我的请求是否正确发送,而不是在应用程序中运行它们.这是我的测试:
public class NetworkCommunicationTest extends AndroidTestCase {
private static final String JSON_URL = "https://www.example.com/data.json";
Context context;
@Test
public void testSendGet() {
context = new MockContext();
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET,JSON_URL, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Assert.assertTrue("",true);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
}
});
RequestQueue requestQueue = Volley.newRequestQueue(context);
requestQueue.add(jsonObjectRequest);
}
}
Run Code Online (Sandbox Code Playgroud)
我已将此库添加到Android Studio项目中,但我收到此错误:
java.lang.NullPointerException
at com.android.volley.toolbox.Volley.newRequestQueue(Volley.java:48)
at com.android.volley.toolbox.Volley.newRequestQueue(Volley.java:78)
at tests.NetworkCommunicationTest.testSendPost(NetworkCommunicationTest.java:47) …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在Apache服务器上使用通过StartSSL.com获得的SSL证书.与浏览器的连接很好,但是当我尝试使用Java应用程序时,我得到了这个例外:
线程"main"中的异常javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到所请求目标的有效证书路径
我不明白可能是什么问题,因为在浏览器中,我获得了带有绿色标签的SSL.
我想在一个组件中检测我的 HTTP 请求的 401 响应代码:
@Injectable()
export class InterceptorProvider implements HttpInterceptor {
constructor(private authService: AuthenticationService) { }
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
console.log(request);
return next.handle(request);
}
Run Code Online (Sandbox Code Playgroud)
如何捕获错误,执行刷新令牌请求,并在响应代码正常的情况下让其他组件继续?
更新
@Injectable()
Run Code Online (Sandbox Code Playgroud)
导出类 InterceptorProvider 实现 HttpInterceptor {
constructor(private authService: AuthenticationService, private storage: Storage) { }
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
console.log(request);
return next.handle(request)
.pipe(tap(event => {
if (event instanceof HttpResponse) {
}
}, err => {
if (err instanceof HttpErrorResponse) {
if (err.status === 401) {
console.log(err);
console.log("Retriving user....");
let user …
Run Code Online (Sandbox Code Playgroud) 我已经实现了一种以这种方式导出 PDF 中的一些信息的机制:
public void generatePdf() {
String fileName = "Bolla_" + productionOrder.getOrderNumber();
writePDFToResponse(new GenerateStatusPDF(companyInfo).generate(productionOrder), fileName);
}
private void writePDFToResponse(ByteArrayOutputStream baos, String fileName) {
try {
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
externalContext.responseReset();
externalContext.setResponseContentType("application/pdf");
externalContext.setResponseHeader("Expires", "0");
externalContext.setResponseHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
externalContext.setResponseHeader("Pragma", "public");
externalContext.setResponseHeader("Content-disposition", "attachment, filename=" + fileName + ".pdf");
externalContext.setResponseContentLength(baos.size());
java.io.OutputStream out = externalContext.getResponseOutputStream();
baos.writeTo(out);
externalContext.responseFlushBuffer();
FacesContext.getCurrentInstance().responseComplete();
} catch (Exception e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的.xhtml
文件使用情况:
<h:commandLink>
<p:graphicImage name="/ultima-layout/images/pdf_icon.png"
width="64px" />
<p:fileDownload
value="#{productionOrderStatusView.generatePdf()}" />
</h:commandLink>
Run Code Online (Sandbox Code Playgroud)
我不知道为什么,但最近几天我遇到了一些问题,出现了以下错误:
ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION
Run Code Online (Sandbox Code Playgroud)
我哪里错了?谷歌浏览器可能有一些新的更新吗?
我想将按钮插入到我的 Ionic 4 应用程序中,该按钮以一种形式使用,一旦按下,在等待服务器响应期间,在操作期间,左侧会显示一个环/圆/微调器。它是 Material Design 的一部分,但我在文档中没有找到任何内容。我该如何实施?