How can i use back4app with AngularJS application? [closed] - parsing

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want use Back4App with angularjs application, for simple user login.
Can I do this and how?

Yes this can be done and is done. Use the javascript doc on parse.com http://docs.parseplatform.org/js/guide/
Also there is a nodejs tool. https://www.npmjs.com/package/angular-parse
Are you familiar with Angularjs?
Load angularjs and parse in HTML
In your controller, pass data from your sign in form:
$scope.submitFormReg = function(newUser){
var user = new Parse.User();
user.set("username", newUser.user);
user.set("password", newUser.pass);
user.set("email", newUser.email);
user.signUp(null, {
success: function(user) {
// Hooray! Let them use the app now.
},
error: function(user, error) {
// Show the error message somewhere and let the user try again.
alert("Error: " + error.code + " " + error.message);
Parse.User.logOut().then(() => {
});
}
});
};
$scope.submitFormLogin = function(newUser){
Parse.User.logIn(newUser.user, newUser.pass, {
success: function(user) {
// Do stuff after successful login.
$location.path('/');
},
error: function(user, error) {
// The login failed. Check error to see why.
alert(newUser + " login failed: " + error);
}
});
};

Related

Get generated ID after insert in UI5 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
My problem is, that I need to get the generated ID of a created entry.
I want to create one entry in my ODataModel and then another one. The second one should hold the ID of the first one as property.
But when I insert the first entry with {"Id" : "0"}, so the ID gets automatically generated, I find no way to get the response Header to save the generated ID in a variable.
I tried to save the response out of the success callback, but the variable stays undefined because of the asynchronicity.
Meanwhile I solved the problem by myself.
I moved the creation of the second entry into the success callback of the first entry.
Thus I was able to get the ID out of the "response" parameter and added it as property to my second entry.
That is probably not the best solution but it works for me.
Maybe somebody else has another proposal to do it better.
This is just a samplecode, but maybe it will help some people who got a similar problem.
// oView = this.getView();
// First Entry for EntitySampleSet1
var oEntry = {};
oEntry.Id = "0";
oEntry.Label = oView.byId("label").getValue();
oEntry.Status = oView.byId("status").getValue();
// Success Callback for the first Entry Creation
// response contains the Response Header for the POST Request
var fnSuccessCallback = function(oData, response)
{
console.log("Success 1");
// Success Callback for the second create methode
var fnSuccess2Callback = function()
{
console.log("Success 2");
};
// Error Callback for the second create methode
var fnError2Callback = function()
{
console.log("Error 2");
};
// Second Entry for EntitySampleSet2
var o2Entry = {};
// ID = "0" so the ID gets automatically generated by JPA
o2Entry.Id = "0";
o2Entry.SampleRelatedObject = response.data.Id;
// The second Entry gets created in the OData Model
oModel.create("/SampleEntitySet2", o2Entry,
{
urlParameters : null,
success : fnSuccess2Callback,
error : fnError2Callback
});
};
var fnErrorCallback = function(oError)
{
console.log("Error1");
};
// The first Entry gets created in the OData Model
// after the create worked fine the fnSuccessCallback will get
// called and the second entry will be created in that method
oModel.create("/SampleEntitySet1", oEntry,
{
urlParameters : null,
success : fnSuccessCallback,
error : fnErrorCallback
});

Disposable Temporary Email with attachment download API support [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I am working on an application that uses guerrillamail to get temporary email and then I use its given API's to get the contents of emails sent to this id. What I am not able to achieve is that if email contains attachment how can I download it using API or parse the MIME using a mime parser library if I have the email source?
Or can you please recommend any alternative that provide API support to download attachments.
I tried to see if I could find an answer, so I made some code that seems to work:
var template_content = $("#mail")[0].content;
var tep = $("#mail");
function getMail(id, mail_id) {
$.get("https://api.guerrillamail.com/ajax.php?f=fetch_email&lang=en&sid_token=" + id + "&email_id=" + mail_id, function(mail) {
console.log("Mail:");
console.log(mail);
template_content.querySelector('p:nth-of-type(1)').innerHTML = mail.mail_from;
template_content.querySelector('p:nth-of-type(2)').innerHTML = mail.mail_subject;
template_content.querySelector('p:nth-of-type(3)').innerHTML = mail.mail_body;
if (mail.att == 0) {
template_content.querySelector('span').innerHTML = "-none-";
} else {
var sp = template_content.querySelector('span');
$.each(mail.att_info, function(l, att) {
console.log(att);
var a = document.createElement('a');
console.log(a);
var linkText = document.createTextNode(att.f + " [" + att.t + "]");
a.appendChild(linkText);
a.title = att.f + " [" + att.t + "]";
a.href = "https://www.guerrillamail.com/inbox?get_att&lang=en&sid_token=" + id + "&email_id=" + mail.mail_id + "&part_id=" + att.p;
sp.appendChild(a);
});
}
var clone = document.importNode(template_content, true);
document.querySelector('#mails').appendChild(clone);
});
}
$.get("https://api.guerrillamail.com/ajax.php?f=get_email_address&lang=en", function(data) {
var email = data.email_addr;
var id = data.sid_token;
$("#email_addr").text(email);
$("#pane").show();
$("#get").click(function() {
$.get("https://api.guerrillamail.com/ajax.php?f=get_email_list&lang=en&sid_token=" + id + "&offset=0", function(data) {
console.log(data.list);
var tep = $("#mail");
$.each(data.list, function(i, mail) {
getMail(id, mail.mail_id)
});
});
});
});
p {
display: inline
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="pane" style="display:none">
<p>Send email with attachment to [<b id="email_addr">frefr</b>] and press the button:</p>
<button id="get">Get mails!</button>
</div>
<br/>
<br/>
<div id="mails">
</div>
<template id="mail">
<div>
<h2>Mail</h2>
Sender:
<p>1</p>
<br/>Subject:
<p>2</p>
<br/>Body:
<br/>
<hr/>
<p>3</p>
<br/>
<hr/>Attachments:
<br>
<span></span>
</div>
</template>
I can't find any info about the attachment stuff in the documentation, but in my code I used the "normal" attachment link, and it seems to work:
https://www.guerrillamail.com/inbox?get_att&lang=en&sid_token={sid_token}&email_id={email_id}&part_id={part_id}";
Look at my example code to see how to use it.
You seem to have most of the code done on the iPhone side, basically you just have to add a call to the get_att url with the att parameters from the fetch_email.
Temp Mail seems to have an API that suits your needs. You can retrieve an email attachment with:
https://privatix-temp-mail-v1.p.mashape.com/request/attachments/id/{md5}/
It gives you back a JSON array of all the attachment.

409 http error in Couchbase lite in phonegap on iOS

I'm getting a 409 on PUT, POST and DELETE actions.
I have successfully created a database and have PUT one document successfully ONCE. I have tried local and "normal" documents. I haven't spend any focus on revisions but think it has to do with this. I only want to save and update this one JSON string in my app - thats it.
It's like I have created this one document to stay forever :-)
Will sample code help? I'm really only using Angular's $http.
On a side note: I need a save mechanism in phonegap that is html5 cache-clear resistent.
You need to check if your document exists first before you update it. that's why it worked the first time and not the second.
config.db.get( "myDocumentID", function(error, doc) {
if (error) {
if (error.status == 404) {
//document does not exist insert it
config.db.put( "myDocumentID", myDocument, function(error,ok) {
if(error) { alert( "error" + JSON.stringify( error ) } else {
alert("success");
}
} )
} else {
alert( "error:" + JSON.stringify( error ) )
}
} else {
//update your document
doc.my_new_key = "value";
config.db.put( "myDocumentID", doc, function(error, ok) {
if( error ) { alert( "error:" + JSON.stringify( error ) ) } else {
alert("success");
}
} );
}
} )

Cordova/Phonegap Facebook Plugin Example/Best Practices

I'm building an app for iOS using Cordova and would like to integrate some facebook graph api functionality. Although I have the login working, I'm having trouble getting the api() function to return data. I'm currently trying to get a users friends list but an example of any workflow would be helpful.
Here's what I have so far, do I need to call the init function? It's not available under the facebookConnectPlugin object which makes me think I don't need it but maybe I need to use CDV.FB.init() or FB.init()?
var fbLoginSuccess = function (userData) {
facebookConnectPlugin.api('/me/friends?fields=picture,name', ["basic_info", "user_friends"],
function (result) {
alert("Result: " + JSON.stringify(result));
},
function (error) {
alert("Failed: " + error);
}
);
}
facebookConnectPlugin.login(
["basic_info"],
fbLoginSuccess,
function (error) {
alert("" + error);
}
);
With Graph v2.0, only friends using the same app will be visible to the app.

Is there any Facebook plugin for phonegap 2.7.0? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Is there any Facebook plugin for Phonegap 2.7.0?
When we try the below one, we are end up with deprecated error on Phonegap 2.7.0.
https://github.com/phonegap/phonegap-facebook-plugin/blob/master/README.md
We couldn't find anything when we Google it.
Thank you,
Sid
I would suggest you use the inappbrowser plugin that comes with phonegap to do this .. example shown below.
Fill in the xxx below with your relevant info
var my_client_id = "xxxxxx", // YOUR APP ID
my_secret = "xxxxxxxxx", // YOUR APP SECRET
my_redirect_uri = "https://www.facebook.com/connect/login_success.html", // LEAVE THIS
my_type ="user_agent", my_display = "touch"; // LEAVE THIS
var facebook_token = "fbToken"; // OUR TOKEN KEEPER
var ref; //IN APP BROWSER REFERENCE
// FACEBOOK
var Facebook = {
init:function(){
// Begin Authorization
var authorize_url = "https://www.facebook.com/dialog/oauth?";
authorize_url += "client_id=" + my_client_id;
authorize_url += "&redirect_uri=" + my_redirect_uri;
authorize_url += "&display=" + my_display;
authorize_url += "&scope=publish_stream";
//CALL IN APP BROWSER WITH THE LINK
ref = window.open(authorize_url, '_blank', 'location=no');
ref.addEventListener('loadstart', function(event){
Facebook.facebookLocChanged(event.url);
});
},
facebookLocChanged:function(loc){
if (loc.indexOf("code=") >= 1 ) {
//CLOSE INAPPBROWSER AND NAVIGATE TO INDEX
ref.close();
//THIS IS MEANT TO BE DONE ON SERVER SIDE TO PROTECT CLIENT SECRET
var codeUrl = 'https://graph.facebook.com/oauth/access_token?client_id='+my_client_id+'&client_secret='+my_secret+'&redirect_uri='+my_redirect_uri+'&code='+loc.split("=")[1];
console.log('CODE_URL::' + codeUrl);
$.ajax({
url: codeUrl,
data: {},
type: 'POST',
async: false,
cache: false,
success: function(data, status){
//WE STORE THE TOKEN HERE
localStorage.setItem(facebook_token, data.split('=')[1].split('&')[0]);
},
error: function(){
alert("Unknown error Occured");
}
});
}
}
I would add more functions for logout and posting to a wall etc.
You can find documenatation on the inappbrowser here

Resources