My app creates a contact item that is used to communicate images to the application via a timeline subscription.
When I am deleting contacts via the REST API I am getting a success status and when I list the contact items via the REST API I can verify that the contact is removed.
But on the device itself the contact is still there. Only when I shutdown and startup the device the contact is gone. How can I make that happen immediately after my request?
My Device info: XE9 up to date. The device has a connection and I can update/delete timeline items without any problem.
Deletion of contacts can happen by your Glassware only if those contacts were inserted into your Glass by the same Glassware.
I have tried this DeleteAllContacts code, that works pretty well.
NewUserBootstrapper.deleteAllContacts(MirrorClient.getMirror(credential), credential);
and this is the method.
private static void deleteAllContacts(Mirror service, Credential credential)
{
try {
ContactsListResponse contacts = service.contacts().list().execute();
for (Contact contact : contacts.getItems())
{
LOG.info("Contact ID: " + contact.getId());
LOG.info(" > displayName: " + contact.getDisplayName());
if (contact.getImageUrls() != null) {
for (String imageUrl : contact.getImageUrls()) {
LOG.info(" > imageUrl: " + imageUrl);
}
}
MirrorClient.deleteContact(credential, contact.getId());
}
}catch (IOException ioe) {
LOG.warning("An error occurred: " + ioe.getMessage());
}
}
Related
i manage my users with the Firebase Admin SDK.
On signup i send email,password and username to my endpoint.
i createUserWithEmailAndPassword and create a doc in my firestore
This way i can check if a document already exists and return an error that the username/handle is already taken.
Firestore
- users
- handle
* email
* userId (from createUserWithAndPassword Response)
* createdAt
After the user signInWithEmailandPassword i only have the token, email and userId.. but i need the handle to get the right user details.
what i get from the docs is that there is a default displayName property but i dont know how to set it on signup.
or should i create a custom Token and store the handle inside of it..
im not sure how to go from here
thanks for your help
This is a simple method for what you want:
mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if(task.isSuccessful()){
// Sign in success
FirebaseUser user = mAuth.getCurrentUser();
UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
.setDisplayName(mName).build();
user.updateProfile(profileUpdates).addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "User profile updated.");
}
}
});
}
});
Then, to retrieve it, use this wherever required:
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
// Name, email address etc
String name = user.getDisplayName();
String email = user.getEmail();
}
There are multiple ways, but I recommend to use this one :)
I have downloaded, configured and deployed the Microsoft Virtual Assistant open source project from GitHub here: https://github.com/Microsoft/AI
I want to start with the calendar skill and have configured everything.
When I request my current calendar entries, the authentication prompt is shown in the botframework emulator and I am able to authenticate with my Azure AD Account.
After that, there is silence...
In SummaryDialog.cs in the CalendarSkill there is a definition for a WaterfallStep like this:
var showSummary = new WaterfallStep[]
{
GetAuthToken,
AfterGetAuthToken,
ShowEventsSummary,
CallReadEventDialog,
AskForShowOverview,
AfterAskForShowOverview
};
The step GetAuthToken is executed, but then execution stops. AfterGetAuthToken is not called at all.
This is the GetAuthToken function inside the project:
protected async Task<DialogTurnResult> GetAuthToken(WaterfallStepContext sc, CancellationToken cancellationToken)
{
try
{
var skillOptions = (CalendarSkillDialogOptions)sc.Options;
// If in Skill mode we ask the calling Bot for the token
if (skillOptions != null && skillOptions.SkillMode)
{
// We trigger a Token Request from the Parent Bot by sending a "TokenRequest" event back and then waiting for a "TokenResponse"
// TODO Error handling - if we get a new activity that isn't an event
var response = sc.Context.Activity.CreateReply();
response.Type = ActivityTypes.Event;
response.Name = "tokens/request";
// Send the tokens/request Event
await sc.Context.SendActivityAsync(response);
// Wait for the tokens/response event
return await sc.PromptAsync(SkillModeAuth, new PromptOptions());
}
else
{
return await sc.PromptAsync(nameof(MultiProviderAuthDialog), new PromptOptions());
}
}
catch (SkillException ex)
{
await HandleDialogExceptions(sc, ex);
return new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs);
}
catch (Exception ex)
{
await HandleDialogExceptions(sc, ex);
return new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs);
}
}
Am I doing anything wrong in the code or is there anything missing in my configuration?
I found out, if ngrok is not on the PC and configured, the virtual Assistatn does not work.
I'm new to backend servers and hosting files so if you could give me a starting point just to undersand how it works.
If I can log in with a facebook profile somehow this data saved in the dropbox and if I try to log in again with a different profile I face this
"The current user has a Facebook profile and it’s not the profile they have just tried to log in with" this from the GameSparks documentation which turns into error <"accessToken":"ACCOUNT_ALREADY_LINKED">recieved from GameSparks
Solved
after 12 hours I discovered that u have to disconnect from the server and reconnect
forexample when you want to link a facebook profile the server is now connected to that user so when you want to link another profile u have to disconnect from the previous profile and connect then wait till the server is available then you could link the new profile
using GameSparks.Api.Requests;
using GameSparks.Api.Messages;
using GameSparks.Api.Responses;
using GameSparks.Core;
public void Awake()
{
FB.Canvas.SetAspectRatio(9,16,FBScreen.CenterHorizontal());
if (!FB.IsInitialized)
{
FB.Init(FacebookLogin);
}
else
{
FacebookLogin();
}
}
public void FacebookLogin()
{
if (!FB.IsLoggedIn)
{
FB.Login("email", GameSparksLogin);
}
}
public void GameSparksLogin(FBResult result)
{
StartCoroutine (GameSparksLoginProcess ());
}
IEnumerator GameSparksLoginProcess(){
GS.Reset ();
float i = 0;
while (true) {
if(!(GS.Available)){
i += 0.2f;
yield return new WaitForSeconds(0.2f);
}else{
Debug.Log("wait: "+i+" seconds");
break;
}
}
if (FB.IsLoggedIn)
{
new FacebookConnectRequest().SetAccessToken(FB.AccessToken).SetDoNotLinkToCurrentPlayer(false)
.Send((response) =>
{
if (response.HasErrors)
{
Debug.Log("Something failed when connectiong with Facebook");
}
else
{
Debug.Log("GameSparks Facebook Login Successful");
}
});
}
}
I'm using Twilio's NodeJS module & API to send out MMS messages with images attached (from a remote URL), and I want to delete the Media instances that get created on Twilio servers as soon as I send out the messages.
My messages send out correctly, and in the callback, I'm trying to 1) list media instances for the current message, then 2) loop through those instances and delete. The problem is that the mediaList array that comes back from the API for a current message is always empty.
Here's my code:
twilio_client.messages.create({
body: "Thanks for taking a photo. Here it is!",
to: req.query.From,
from: TWILIO_SHORTCODE,
mediaUrl: photo_URL,
statusCallback: STATUS_CALLBACK_URL
}, function(error, message) {
if (!error) {
twilio_client.messages(message.sid).media.list(function(err, data) {
console.log(data);
// The correct object comes back as 'data' here per the API
// but the mediaList array is empty
}
console.log('Message sent via Twilio.');
res.status(200).send('');
} else {
console.log('Could not send message via Twilio: ');
console.log(error);
res.status(500).send('');
}
});
So, it turns out that trying to get the media list at the point I was trying to doesn't work because the media instances didn't exist yet.
I have a separate little app running at the statusCallback (I supply a URL via a constant in the code above, STATUS_CALLBACK_URL), that until now, just checked to see if a message I tried to MMS to a user wasn't handled properly by Twilio, and alerted the user to a problem via SMS. So, I added a check in that same app to see if the message was actually 'sent' to the user, and then checked for and deleted the media instance(s) associated with the message at that point, and it works fine. Here's my code:
// issue message to user if there's a problem with Twilio getting the photo
if (req.body.SmsStatus === 'undelivered' || req.body.SmsStatus === 'failed') {
twilio_client.messages.create({
body: "We're sorry, but we couldn't process your photo. Please try again.",
to: req.body.To,
from: TWILIO_SHORTCODE
}, function(error, message) {
if (!error) {
console.log('Processing error message sent via Twilio.');
res.send(200,'');
} else {
console.log('Could not send processing error message via Twilio: ' + error);
res.send(500);
}
});
}
// delete media instance from Twilio servers
if (req.body.SmsStatus === 'sent') {
twilio_client.messages(req.body.MessageSid).media.list(function(err, data) {
if (data.media_list.length > 0) {
data.media_list.forEach(function(mediaElement) {
twilio_client.media(mediaElement.sid).delete;
console.log("Twilio media instance deleted");
});
}
});
}
I'm developing a membership sign up app for an organization on Google App Engine, for new members, they can use a sign up page to become a member, is there a way in Google App Engine to add new members as gmail contacts ? So each time a new user clicks a submit button with his info, a new gmail contact is auto generated and added to my contact list [ my gmail address is registered with the GAE app ].
Here is some of my code try to do that, but it doesn't add new contacts each a submit button is pressed :
String Add_New_Contact_Url="https://www.google.com/m8/feeds/contacts/default/full";
protected void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
{
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8"); // UTF-8 GB18030
PrintWriter out=response.getWriter();
String Email=request.getParameter("Email");
if (Email==null || Email.trim().length()<1)
{
StrBuf=new StringBuffer("<Html><Head><Title>Signup</Title></Head>\n<Body>\n");
StrBuf.append("<P><Br><P><Br><P>\n");
StrBuf.append("<Table Border=1 Align=Center Cellpadding=8 Cellspacing=1><Tr Bgcolor=\"#0088FF\" Colspan=2><Th><Font Color=White>Sign up</Font></Th></Tr></Table>\n<P>\n");
StrBuf.append("<Center>\n");
StrBuf.append("<Form Name=Singles_Club_Signup_Form>\n");
StrBuf.append("<Table Border=1 Cellpadding=6 Cellspacing=1>\n");
...
StrBuf.append("<Tr><Td Align=Right><B><Font Size=3 Color=#0066FF>Email</Font></B></Td><Td><Input type=text name=Email size=36 /></Td></Tr>\n");
...
StrBuf.append("</Table>\n");
StrBuf.append("<P><Br><P>\n");
StrBuf.append("<Input type=submit value=Sign_Up/>\n");
StrBuf.append("</Form>\n");
StrBuf.append("</Center>\n");
StrBuf.append("</Body>\n</Html>");
}
else
{
try
{
LinkedHashMap<String,String> Key_Value_Pairs=new LinkedHashMap<String,String>();
String A_Contact=createContact(Email);
Key_Value_Pairs.put("A",A_Contact);
getFromUrlDoPost(Add_New_Contact_Url,Key_Value_Pairs); // Create new contact in Gmail account
}
catch (Exception e) { out.println(e.toString()); }
finally { if (pm!=null) pm.close(); }
}
}
String createContact(String Email)
{
return "<atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'>\n"+
"<atom:category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact' />\n"+
"<gd:name>\n"+
"<gd:givenName>AAA</gd:givenName>\n"+
"<gd:familyName>BBB</gd:familyName>\n"+
"<gd:fullName>AAA BBB</gd:fullName>\n"+
"</gd:name>\n"+
"<atom:content type='text'>Notes</atom:content>\n"+
"<gd:email rel='http://schemas.google.com/g/2005#work' primary='true' address='"+Email+"' displayName='E. Bennet' />\n"+
"<gd:email rel='http://schemas.google.com/g/2005#home' address='liz#example.org' />\n"+
"<gd:phoneNumber rel='http://schemas.google.com/g/2005#work' primary='true'>\n"+
"(206)555-1212\n"+
"</gd:phoneNumber>\n"+
"<gd:phoneNumber rel='http://schemas.google.com/g/2005#home'>\n"+
"(206)555-1213\n"+
"</gd:phoneNumber>\n"+
"<gd:im address='liz#gmail.com' protocol='http://schemas.google.com/g/2005#GOOGLE_TALK' primary='true' rel='http://schemas.google.com/g/2005#home' />\n"+
"<gd:structuredPostalAddress rel='http://schemas.google.com/g/2005#work' primary='true'>\n"+
"<gd:city>Mountain View</gd:city>\n"+
"<gd:street>1600 Amphitheatre Pkwy</gd:street>\n"+
"<gd:region>CA</gd:region>\n"+
"<gd:postcode>94043</gd:postcode>\n"+
"<gd:country>United States</gd:country>\n"+
"<gd:formattedAddress>\n"+
"1600 Amphitheatre Pkwy Mountain View\n"+
"</gd:formattedAddress>\n"+
"</gd:structuredPostalAddress>\n"+
"</atom:entry>";
}
StringBuffer getFromUrlDoPost(String A_Url,LinkedHashMap Key_Value_Pairs) throws MalformedURLException,IOException
{
StringBuffer Text_Out=new StringBuffer(""),Text_In=new StringBuffer("");
String data="",key,value,inputLine;
try // Sending a POST Request Using a URL
{
// Construct data -- List the entries
for (Iterator it=Key_Value_Pairs.keySet().iterator();it.hasNext();)
{
key=it.next().toString();
value=Key_Value_Pairs.get(key).toString();
if (data.length()==0) data=URLEncoder.encode(key,"UTF-8")+"="+URLEncoder.encode(value,"UTF-8");
else data+="&"+URLEncoder.encode(key,"UTF-8")+"="+URLEncoder.encode(value,"UTF-8");
}
// Send data
URLConnection conn=new URL(A_Url).openConnection();
conn.setRequestProperty("Content-Type","application/atom+xml");
conn.setDoOutput(true);
OutputStreamWriter wr=new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
Text_In.setLength(0);
// Get the response
BufferedReader rd=new BufferedReader(new InputStreamReader(conn.getInputStream()));
while ((inputLine=rd.readLine()) != null) Text_In.append(inputLine+"\n");
wr.close();
rd.close();
}
catch (Exception e) { }
return Text_In;
}
It doesn't cause error either, what did I do wrong ? I suspect this line :
Key_Value_Pairs.put("A",A_Contact);
Because I don't know what to put in the place of "A" ?
Your users can authorize your application (via OAuth) to interact with their gmail contact list via the Contacts Data API.
I found out why : don't need to include google-collect-*.jar, source of error.