When verifying the signature, the background server displays {"rtnCode":-1,"errMsg":"check playerSSign fail"}
The data provided by the client is
if(huaweiid != null){
PlayersClient player = Games.getPlayersClient(this, huaweiid);
player.getCurrentPlayer().addOnSuccessListener(new OnSuccessListener<Player>() {
#Override
public void onSuccess(Player player) {
String ts = player.getSignTs();
String playerId = player.getPlayerId();
int playerLevel = player.getLevel();
String playerSign = player.getPlayerSign();
//String displayName = player.getDisplayName();
//Uri hiResImageUri = player.getHiResImageUri();
//Uri iconImageUri = player.getIconImageUri();
JSONObject jo = new JSONObject();
try {
jo.put("signTs", ts);
jo.put("playerId", playerId);
jo.put("playerLevel", playerLevel);
jo.put("playerSign", playerSign);
EditText ed = findViewById(R.id.editText);
ed.setText(jo.toString());
Log.i("huawei user info", jo.toString());
} catch (JSONException e) {
e.printStackTrace();
Log.i("huawei user info", Objects.requireNonNull(e.getMessage()));
}
}
});
}
Use the preceding four data items and the following description document:
https://developer.huawei.com/consumer/cn/doc/HMSCore-References-V5/verify-login-signature-0000001050123503-V5
An error always occurs during the verification in the background.
{"rtnCode":-1,"errMsg":"check playerSSign fail"}
appId/cpid is obtained from agconnect-services.json and agconnect-services.json is downloaded from the background.
what’s the reason?
The following table describes the typical setting errors of the input parameters. Please verify the parameter settings.
https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-Guides/faq-check-login-0000001050746133-V5
Related
After getting the following code to work reliably for a month or so, it stopped working reliably a couple of days ago. About half the time it returns a properly translated string and the other half of the time it returns one of the following two messages:
java.io.FileNotFoundException:
https://api.cognitive.microsoft.com/sts/v1.0/issueToken
java.net.UnknownHostException: Unable to resolve host
"api.microsofttranslator.com": No address associated with hostname
The timing of this problem's beginning coincided with the expiration of my free azure cognitive services account however I migrated to a pay-as-you-go account yesterday and the problem continues.
Why is this happening?
static class translateMessageX extends AsyncTask<String, Void, String>
{
//input string array of 3 items
//[0]is the message to be translated
//[1]is the from language i.e. "english"
//[2]is the to language i.e. "spanish"
//[3]"echo" or "received"
String retString;
String inString = null;
String messageType = null;
String URLHolder = ""; //hold the URL here while we are translating the text
#Override
protected String doInBackground(String... params)
{
inString = params[0];
String from = params[1];
String to = params[2];
messageType = params[3];
int urlStart = inString.indexOf("http");
if (!(urlStart == -1))
{
URLHolder = inString.substring(urlStart);
inString = inString.substring(0, urlStart -1);
}
else
{
URLHolder = "";
}
Integer mesChars = params[0].length();
Integer tCharsLeft = GlobalStuff.getTranslationsFromSP();
if (tCharsLeft > 0)
{
if (tCharsLeft < mesChars) //we charge for both 'echo' and 'received' translations
{
GlobalStuff.updateTranslationInventory(tCharsLeft * -1);
}
else
{
GlobalStuff.updateTranslationInventory(mesChars * -1);
}
GlobalStuff.notifyListeners(this, "#uui", "notused", "notused" );
try
{
Language fromLang = GlobalStuff.getLang(from);
Language toLang = GlobalStuff.getLang(to);
//retString = Translate.execute(inString, fromLang, toLang);
//String debugstr = "look at retStr";
String authenticationUrl = "https://api.cognitive.microsoft.com/sts/v1.0/issueToken";
HttpsURLConnection authConn = (HttpsURLConnection) new URL(authenticationUrl).openConnection();
authConn.setRequestMethod("POST");
authConn.setDoOutput(true);
authConn.setRequestProperty("Ocp-Apim-Subscription-Key", GlobalStuff.translateKey);
IOUtils.write("", authConn.getOutputStream(), "UTF-8");
String token = IOUtils.toString(authConn.getInputStream(), "UTF-8");
System.out.println(token);
// Using the access token to build the appid for the request url
String appId = URLEncoder.encode("Bearer "+token, "UTF-8");
String text = URLEncoder.encode(inString, "UTF-8");
String translatorTextApiUrl = String.format("https://api.microsofttranslator.com/v2/http.svc/Translate?appid=%s&text=%s&from=%s&to=%s", appId, text, fromLang, toLang);
HttpsURLConnection translateConn = (HttpsURLConnection) new URL(translatorTextApiUrl).openConnection();
translateConn.setRequestMethod("GET");
translateConn.setRequestProperty("Accept", "application/xml");
retString = IOUtils.toString(translateConn.getInputStream(), "UTF-8");
String debug = "look at retString";
}
catch (Exception e)
{
retString = e.toString();
}
}
else
{
retString = "OUT OF TRANSLATION CREDITS - " + inString;
}
return retString;
}
#Override
protected void onPostExecute(String result)
{
//rest of logic should be here??
String debug = "look at result";
String answer = extractTranslation(result);
.. . . .
Host not found looks like a simple connectivity error. These hosts do exist.
You can void the call to the token service by passing the key in the call to api.microsofttranslator.com directly:
https://cognitive.uservoice.com/knowledgebase/articles/1815385-api-translator-text-speech-using-the-api-key
That fixes one of the host not found problems, but not the other.
I would recommend though to not embed the key in the client application. It is safer to call the translator service from your own proxy service, where the proxy is able to safely identify your client as your client.
I have a problem pushing data to my index. My code is as follows:
Client client = new Client("APP_ID", "SEARCH_ID");
Index myIndex = client.initIndex("test");
JSONObject jsonObject = null;
try {
jsonObject = new JSONObject()
.put("name", "Jimmie")
.put("username", "Barninger")
} catch (JSONException e) {
e.printStackTrace();
}
myIndex.addObjectAsync(jsonObject, null);
However nothing happens, and no data is visible in my dashboard. What am I doing wrong?
I had to change the api keys which previously was SEARCH_ID. I changed it to my ADMIN_API_KEY:
Client client = new Client("APP_ID", "ADMIN_API_KEY");
This is because the search-only API key can only be used for searching, while the Admin API key can change, delete or add an object.
The full code is now:
Client client = new Client("APP_ID", "ADMIN_API_KEY");
Index myIndex = client.initIndex("test");
JSONObject object = null;
try {
object = new JSONObject()
.put("username", "Jimmie")
.put("name", "Barninger");
} catch (JSONException e) {
e.printStackTrace();
}
// myIndex.addObjectAsync(object, "myID", null);
myIndex.addObjectAsync(object, "id", null);
In order to understand more, please replace the addobjectAsync line with something like this:
index.addObjectAsync(object, new CompletionHandler() {
#Override
public void requestCompleted(JSONObject content, AlgoliaException error) {
if (error != null) {
// Check what is the error Here
}
}
}
With reference of that enter link description here
I have send message successfully but I want to send custom header as well because of get status which particular message has send to update user
public void sendInstantMessage(String number, String msgBody) {
String sipServer = "aaa.ggg.net";
String buddy_uri = "<sip:" + number + "#" + sipServer + ">";
BuddyConfig bCfg = new BuddyConfig();
bCfg.setUri(buddy_uri);
bCfg.setSubscribe(false);
MyBuddy myBuddy = new MyBuddy(bCfg);
SendInstantMessageParam prm = new SendInstantMessageParam();
prm.setContent(msgBody);
// prm.setUserData(value)
try {
myBuddy.create(account, bCfg);
myBuddy.sendInstantMessage(prm);
myBuddy.delete();
} catch (Exception e) {
e.printStackTrace();
return;
}
}
By using `Token pj::SendInstantMessageParam::userData for link enter link description here
I want to send the userdata header, but how to sent that header??
Thanks
Finally I got the solution for sending SMS with custom header using pjsip-2.4
Here is the code
String msgBody = "sending message";
SendInstantMessageParam prm = new SendInstantMessageParam();
prm.setContent(msgBody);
SipHeader hName = new SipHeader();
hName.setHName("name");
hName.setHValue(uniqueId);
SipHeaderVector headerVector = new SipHeaderVector();
headerVector.add(hName);
SipTxOption option = new SipTxOption();
option.setHeaders(headerVector);
prm.setTxOption(option);
try {
myBuddy.sendInstantMessage(prm);
} catch (Exception e) {
e.printStackTrace();
}
The situation is as following:
I send a login request using the method showLoginUI and then, after selecting a provider (Twitter, g+, etc.) the app goes to the onError callback of my GSLoginUIListener with the error "Account pending registration". Until that point, everything is fine. The problem is when I try to create another GSRequest with the method "accounts.setAccountInfo" like in the following code:
GSRequest setAccountInfoRequest = new GSRequest(getString(R.string.gigya_api_key),"accounts.setAccountInfo");
As parameter, I believe I have to add the regToken but where can I get it? In the iOS SDK, there is an Error object (that you get from the GSResponse that allows you to get it like this:
token = error.userInfo["regToken"]
But there is nothing like that on the Android SDK, from the GSResponse I just can get the error code, error message and error details. So, in short, how can I get the regToken that I need for my request? In the documentation does not go into the details of the actual implementation and I have not seen any examples.
Unlike the iOS and .NET SDKs, the Android SDK does not have a publicly expose or documented GSRequest class, so invoking a request the way you are doing it is not advisable.
Instead, you should use GSAPI.sendRequest with a GSResponseListener. The GSResponseListener will have a response object with the method getData which can be invoked to get a dictionary object of all the parameters returned from the request.
An example of how this can be done is provided in our Gigya CS Android demo hosted on GitHub and can be examined in the file SessionInfoFragment.java#121-191.
public void refreshView() {
GSAPI gigya = GSAPI.getInstance();
final TextView statusText = (TextView) rootView.findViewById(R.id.status_value);
final TextView nameText = (TextView) rootView.findViewById(R.id.name_value);
final TextView emailText = (TextView) rootView.findViewById(R.id.email_value);
final ImageView avatarView = (ImageView) rootView.findViewById(R.id.avatar);
if (gigya.getSession() != null){
if (gigya.getSession().isValid()) {
MainActivity parent = (MainActivity) getActivity();
GSObject user = parent.getUser();
// Retrieve the user if it's not set. (Reloaded app with active session)
if (user == null) {
GSResponseListener resListener = new GSResponseListener() {
#Override
public void onGSResponse(String method, GSResponse response, Object context) {
try {
if (response.getErrorCode()==0) { // SUCCESS! response status = OK
MainActivity parent = (MainActivity) getActivity();
Log.w("Gigya-Android-Demos", "Successfully set user");
parent.setUser(response.getData());
setLoggedIn(statusText, nameText, emailText, avatarView, response.getData());
} else { // Error
Log.w("Gigya-Android-Demos", "GSResponse: 'getAccountInfo' returned an error");
Log.w("Gigya-Android-Demos", response.getErrorMessage());
}
} catch (Exception ex) { ex.printStackTrace(); }
}
};
GSAPI.getInstance()
.sendRequest("accounts.getAccountInfo", null, resListener, null );
} else {
// Grab the user data
setLoggedIn(statusText, nameText, emailText, avatarView, user);
}
} else {
setLoggedOut(statusText, nameText, emailText, avatarView);
}
} else {
setLoggedOut(statusText, nameText, emailText, avatarView);
}
}
public void setLoggedOut(TextView status, TextView name, TextView email, ImageView avatar) {
status.setText(getString(R.string.logged_out));
name.setText(getString(R.string.null_value));
email.setText(getString(R.string.null_value));
setUnknownAvatar(avatar);
}
public void setLoggedIn(TextView status, TextView name, TextView emailView, ImageView avatar, GSObject user) {
status.setText(getString(R.string.logged_in));
try {
GSObject profile = user.getObject("profile");
String first = profile.getString("firstName");
String last = profile.getString("lastName");
String email = profile.getString("email");
if (profile.containsKey("photoURL")) {
setAvatar(avatar,profile.getString("photoURL"));
} else {
setUnknownAvatar(avatar);
}
name.setText(first + " " + last);
emailView.setText(email);
} catch (Exception ex) {
Log.w("Gigya-Android-Demos", "Something went horribly wrong with the user!");
ex.printStackTrace();
}
}
You should notice the use of getData() and GSObject classes throughout the example provided. Using this method of making a request, you should be able to examine the response data including the regToken.
In my android app using the Google+ API, I am able to write moments of type "ReviewActivity" with the following code :
ItemScope rating = new ItemScope.Builder()
.setType("http://schema.org/Rating")
.setRatingValue(Float.toString(oeuvre.getRating()))
.setBestRating("5").setWorstRating("0").build();
ItemScope result = new ItemScope.Builder()
.setType("http://schema.org/Review").setName(titre)
.setUrl(urlfreebase)
.setDescription(oeuvre.getNomPeintre()).setReviewRating(rating)
.build();
ItemScope target = new ItemScope.Builder().setUrl(urlfreebase).build();
Moment moment = new Moment.Builder()
.setType("http://schemas.google.com/ReviewActivity")
.setTarget(target).setResult(result).build();
if (monPlusClient.isConnected()) {
monPlusClient.writeMoment(moment);
}
Its works, I can read them in my Google+ profile with my Desktop.
When I load moments, at the beginning of my app, I am also able to read my moments, but I am unable to get the rating value that was chose by the user.
In my listener :
public void onMomentsLoaded(ConnectionResult status,
MomentBuffer momentBuffer, String nextPageToken, String updated) {
...
}
I receive this target :
{"description":"Pablo Picasso","url":"https:\/\/developers.google.com\/+\/web\/snippet\/examples\/review","id":"https:\/\/developers.google.com\/+\/web\/snippet\/examples\/review","reviewRating":{"ratingValue":"4.0","worstRating":"0","bestRating":"5"},"name":"Le Pigeon aux petits pois"}
As you can see the rating is correctly set :
"reviewRating":{"ratingValue":"4.0","worstRating":"0","bestRating":"5"}
but when I try to read it through the API with :
ItemScope res = m.getResult();
String titre = res.getName();
String desc = res.getDescription();
String streval = res.getRatingValue();
the String streval is always null
I solved this by using JSON strings :
ItemScope res = m.getResult();
String titre = res.getName();
String desc = res.getDescription();
try {
JSONObject jres = new JSONObject(res.toString());
JSONObject jeval = jres.getJSONObject("reviewRating");
String streval = jeval.getString("ratingValue");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}