This is my code:
#GET()
Call getMessage(#Url String url);
I am trying to build a chatbot app. But when I try to send a message the app crashes.
Related
We have application that integrates with Slack API and sends the messages via https://api.slack.com/methods/chat.postMessage Slack API. Recently this API started to failing to sent messages to users with error message: method_deprecated. I cannot find the reason why it's deprecated and stopped working in last month.
In order to sent message we use following:
String userId = slackFacade.getUserId(recipientEmail);
String channelId = slackFacade.getDirectChannelId(userId);
slackFacade.postMessage(
Message.builder()
.channel(channelId)
.text(message)
.mrkdwn(true)
.attachment(attachment)
.build());
where slackFacade implementation looks like:
public String getUserId(String email) throws SlackCommunicationException {
return logErrors(slackClient.getUserByEmail(email)).getUser().getId(); //users.lookupByEmail
}
public String getDirectChannelId(String userId) throws SlackCommunicationException {
return logErrors(slackClient.imOpen(userId)).getChannel().getId();
}
I've found the root cause. Actually it was not problem with chat.postMessage but it was part of the changes related to imOpen API:
https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api
I am trying to generate access token for twilio chat but got this error:I have been trying to figure out where the error is coming from but can't get it figured out. I will really appreciate your help. Thanks
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.zihron.projectmanagementapp, PID: 16355
java.lang.Error: javax.xml.datatype.DatatypeConfigurationException: Provider org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl not found
at javax.xml.bind.DatatypeConverterImpl.<clinit>(DatatypeConverterImpl.java:744)
at javax.xml.bind.DatatypeConverter.<clinit>(DatatypeConverter.java:78)
at javax.xml.bind.DatatypeConverter.printBase64Binary(DatatypeConverter.java:547)
at io.jsonwebtoken.impl.Base64Codec.encode(Base64Codec.java:24)
at io.jsonwebtoken.impl.Base64UrlCodec.encode(Base64UrlCodec.java:22)
at
io.jsonwebtoken.impl.AbstractTextCodec.encode(AbstractTextCodec.java:31)
at io.jsonwebtoken.impl.DefaultJwtBuilder.base64UrlEncode(DefaultJwtBuilder.java:314)
at io.jsonwebtoken.impl.DefaultJwtBuilder.compact(DefaultJwtBuilder.java:282)
at com.twilio.jwt.Jwt.toJwt(Jwt.java:100)
at ZihronChatApp.token.TokenGenerator.getToken(TokenGenerator.java:34)
at com.zihron.projectmanagementapp.ChatActivity.onCreateView(ChatActivity.java:43)
I have my details below:
public AccessToken getToken() {
// Required for all types of tokens
String twilioAccountSid ="AC601f2c7***7ed***640***264c***d0d";
String twilioApiKey = "SK684***dda***c81****6c4a****093**";
String twilioApiSecret ="96****dbc06****b74d50***b9***3*4";
String serviceSid="IS***a29****e24****5d****4b20**3e*";
String identity = "joshua.hamilton#gmail.com";
ChatGrant grant = new ChatGrant();
grant.setServiceSid(serviceSid);
AccessToken token = new AccessToken.Builder(twilioAccountSid,
twilioApiKey, twilioApiSecret)
.identity(identity).grant(grant).build();
Log.e("++==--",""+token.toJwt());
//.identity(identity).grant(grant);
return token;
}
Twilio developer evangelist here.
The Twilio Java library is not intended for use within Android projects.
The issue here is that you should not be storing your credentials within your application. A malicious user could decompile your application, take your credentials and abuse them.
Instead, you should create a server (or use some sort of serverless environment, like Twilio Functions) that can run this code and return the token. You should then make an HTTP request from your Android application to fetch that token. Check out the Twilio Programmable Chat Android Quickstart to see how it's done there.
I am trying to integrate Apple Pay in iOS using flutter. I am using method channels to communicate with swift and get the payment process completed. I have followed the documentation which is in this link
However, I believe I have stuck in the very ending part which I don't understand how to continue the flow. Since I am using flutter UIs, I don't need iOS ViewControllers.
This is the code that I have tried so far in the AppDelegate.swift:
func handleApplePayButtonTapped(result: FlutterResult){
let merchantIdentifier = "my.apple.merchant.id"
let paymentRequest = Stripe.paymentRequest(withMerchantIdentifier:merchantIdentifier, country:"US", currency:"USD")
paymentRequest.paymentSummaryItems = [
PKPaymentSummaryItem(label:"Fancy Hat", amount:50.00),
PKPaymentSummaryItem(label:"iHats, Inc", amount:50.00),
]
if Stripe.canSubmitPaymentRequest(paymentRequest){
//next steps ???
result(String("Can submit payment request"))
}else{
result(String("Can't submit payment request"))
}
}
I am calling this code in flutter UI using this code:
Future<void> _doPayment() async {
String returnMsg;
try {
final bool result = await platform.invokeMethod('checkIfDeviceSupportsApplePay');
if(result){
final String status = await platform.invokeMethod('handleApplePayButtonTapped');
print(status);
}
returnMsg = '$result';
} on PlatformException catch (e) {
returnMsg = "Failed: '${e.message}'.";
}
print(returnMsg);}
I already have a Stripe publishable key as well as a Heroku deployed backend. If you checked my swift code, you will see where I am stuck at the moment.
As I have understood the flow, what is remaining to be done is
send the card details to the backend and get a token
using the token, send the payment details to the Stripe server
I am very new to swift language and code samples will be greatly helpful for me to continue with.
Thank you.
It looks like you're following the Stripe Custom iOS Integration, using the native PKPaymentAuthorizationViewController.
You should read through the integration steps here: https://stripe.com/docs/mobile/ios/custom#apple-pay
Basically, your next steps would be
instantiate a PKPaymentAuthorizationViewController with the paymentRequest
Set yourself to its delegate
present the PKPaymentAuthorizationViewController
implement the relevant delegate methods to get back an Apple Pay token (PKToken)
convert PKToken to STPToken (a Stripe token)
All these steps and more are detailed in the link above.
How do I use plivo SMS API in my iOS app using Swift. I read lot of documentation regarding this. I'm not sure how to implement it on swift.
var plivo = require('plivo');
var p = plivo.RestAPI({
authId: 'Your AUTH_ID',
authToken: 'Your AUTH_TOKEN'
});
var params = {
'src': '1111111111', // Sender's phone number with country code
'dst' : '2222222222', // Receiver's phone Number with country code
'text' : "Hi, text from Plivo", // Your SMS Text Message - English
//'text' : "こんにちは、元気ですか?", // Your SMS Text Message - Japanese
//'text' : "Ce est texte généré aléatoirement", // Your SMS Text Message - French
'url' : "http://example.com/report/", // The URL to which with the status of the message is sent
'method' : "GET" // The method used to call the url
};
// Prints the complete response
p.send_message(params, function (status, response) {
console.log('Status: ', status);
console.log('API Response:\n', response);
console.log('Message UUID:\n', response['message_uuid']);
console.log('Api ID:\n', response['api_id']);
});
The above code is in Node.js, I want it to write in swift, and also I'm not sure how to integrate plivo into iOS app. I'm developing an app where it should send a sms to admin whenever user requests an order. So I just want the outgoing message from Plivo to admin. Any suggestions is really helpfull.
Plivo Sales Engineer here. Our recommendation is to host a server to which your iOS app would make a request to send the SMS. Then your server can use a Plivo helper library to make the API request which would send the SMS. This way your AuthID and AuthToken are stored on your server (to which only you have complete access) and you don't expose your Plivo credentials in your iOS app.
If you make a direct request of the Plivo API from your iOS app, then users potentially could find and misuse your credentials.
tl;dr - don't put your authentication credentials in places other people can read it.
So without a helper library you will have to just make use of their REST API. From their site, sending an SMS can be done by POSTing your information to
https://api.plivo.com/v1/Account/{auth_id}/Message/
As for the Swift part take a look at NSMutableURLRequest or if you need help with the networking request you can look at Alamofire
If you want to use Rest API you can do like this:
lazy var plivoRestAPI: PlivoRest = {
let rest = PlivoRest(authId: Constants.Credentials.Plivo.AuthId,
andAuthToken: Constants.Credentials.Plivo.AuthToken)!
rest.delegate = self
return rest
}()
let params = ["to": phoneNumberToCall,
"from": "1111111111",
"answer_url": "",
"answer_method": "GET"]
plivoRestAPI.callOutbound(params)
I am using Appcelerator iCloud·Cloud.Users.login·API its callback is giving me following response:
{"success":false,"error":true,"message":"JSON Parse error: Unexpected identifier \"An\""}
I am stuck on the things and not able to move forward, Our live App users on App Store are also affected from this.
Problem comes when we open Appcelerator Titanium project from Xcode and build the app from there and run on iOS simulator or device.
Here is the code which I am using:
Cloud.Users.login({
login : userId,
password : password,
}, function(e) {
//alert(e);
Ti.API.info("In success ....Cloud.Users.login..");
Ti.API.info('response from login service'+JSON.stringify(e));
if (e.success) {
Ti.API.info('User successfully login');
} else if (e.error) {
Ti.API.info(e.message);
_activityIndicator.hide();
alertWin.close();
}
//button.show();
});
In my case its going in else part because of response which I provided "success":false in the JSON which I am getting in callback function from Appcelerator cloud API.
Help me to resolve this error I am getting in callback.