Since the end of the first week of May 2015, the facebook module function requestWithGraphPath method doesn't return username field anymore (es. john.smith.18#facebook.com).
I'm developing with titanium and that is my code:
fb.requestWithGraphPath('me', {}, 'GET', function(e) {
if (e.success) {
Titanium.API.info(e.result);
}
this is the output:
{"link":"http://www.facebook.com/10000576745____","id":"10000576745___","first_name":"Marco","name":"Marco ______","gender":"male","last_name":"____","locale":"it_IT","timezone":1,"verified":false,"updated_time":"2013-04-27T10:11:08+0000"}
Username field is missing.
Did Facebook changed anything inside the method? Now I can collect only First Name, Last Name, ID, as user identifier fields, but my app uses username field at all!
Any suggestion?
Thank you
The username field was deprecated and is no longer available.
Related
I'm using the customField like my own key. It´s an uniqueID. First question:
Is this the best way to do that?
Second:
I was using ContactApp at Apps Script. I was abble to get the contact using the customField => usserDefined field.
How can do it at poeple api?
function updateContact(first_name,last_name, email, phone, address, custom_address, document, anniversary_day,anniversary_month, anniversary_year, sysCompany, sysJob) {
var contacts = ContactsApp.getContactsByCustomField(document,'CPF');
It´s possible to do it at People API?
So I can fetch a post using this code:
Post post = facebookClient.fetchObject("postId", Post.class, Parameter.with("id", "message","from"));
The "from" field returns the Author's id and name, but not as an User object.
To obtain the User Object I have to send a request again:
User user = facebookClient.fetchObject(post.getFrom().getId, User.class, ..);
This can lead to an insane amount of request calls.
Am I able to fetch them at once?
like this:
MyPost extends Post{
User fetchedUserWithFromFieldId;
}
and somehow invoke:
facebookClient.fetchObject("postId", MyPost.class, Parameter.with("id", "message","from")).deepFetch("fetchedUserWithFromFieldId",User.class, Parameter.with("link","name","location"..etc));
So basically I need the FB equivalent of SQL's join.
Here is the solution:
The parameter fields themselves can be nested.
source: https://restfb.com/documentation/ , Chapter: 'Request with fields (third to n-th level)'
facebookClient.fetchObject("postId", MyPost.class, Parameter.with("id", "message","from{link,name,location}"));
MyPost extends Post{
MyUser user; // MyUser has fields link,name,location.
}
I think what I'm trying to achieve is not hard, but I have no clue how to do it hehehehe !
Basically what I need is the feature that we have in Django Admin, when you are creating a new object, if you have a Foreign Key, you can add new data (opening a pop-up), save it and then the select box updates automatically.
What I have is this form:
I know that would be easy to do it with some Javascript, but my point is, Django has some rules, and as far I know, I can't add new data to a form already created, right? Otherwise Django won't validate this form. How could I achieve this?
PS: "Local" is the select box where I want to add new data. The user should be able to create a new Local on this page, instead of going to another page to do it. Thanks :)
Here your question:
I can't add new data to a form already created, right? Otherwise Django won't validate this form. How could I achieve this?
Then the answer:
you are right, django will check values match form value rules. But:
realize that your main form is invoked for twice: on GET and on POST. Between both form executions you make changes on database values trhough your new form. That means that in second main form invocation the value added to database is available:
field1 = forms.ModelChoiceField(queryset= ***1*** )
***1***: on second invocation new value is already available on field1.
Then, you don't should to be afraid about this subject, the new value will be available on form on your main form POST request.
Nothing wrong with updating the value using javascript as long the key in your new combo box has the right key in the database then it should be ok.
Call this function after you saved the last entry.
function refreshLocal(){
$.get(window.location.href, '', function(html){
// change the id to the local combox's id
var serverLocalDropBox = $(html).find('#id_local');
if (serverLocalDropBox.length){
$('#id_local').replaceWith(serverLocalDropBox);
}
})
}
If you don't want to use javascript solution, you can post the form with refresh flag and on the server side if you see that flag just don't validate and return the form as is. Since you have a new entry in the foreignkey it will automatically update the queryset to include the new entry.
function serverRefreshLocal(){
var $form = $('#your_form_id');
$form.append('<input type="hidden" name="refresh" value="true" />');
// you can use ajax submit and ajax refresh here if you don't want to leave the page
$form.submit();
}
// Server Side
def your_form_post_view(request):
if request.POST.get('refresh', 'false') == 'true':
# initial is the trick to save user input
your_form = YourForm(initial=request.POST)
context = {
'form': your_form,
}
return render(request, 'your_template.html', context)
# your view code goes here
Running Rails 4.2 and devise 3.4.1
I've added "devise :database_authenticatable", to a User model, and everything works exactly as expected .... except, when the record is saved or created I get this error:
Mysql2::Error: Unknown column 'password' in 'field list': UPDATE users SET password = NULL, .....
The devise attribute/method 'password' is clearly being added to the sql but is not a column within the table.
I'm stumped ... Any ideas?
Please check your migration file if there is a encrypted_password field. Next check the structure of users table in database. There should be encrypted_password column too. You can also override devise views and see what happen inside form and try to debug it with console help.
How can I access the data from a model after a find() method?
In Ember-Data 1-0-Beta I can request data from my API via user = this.store.find('user',1) but how can I get the username of the user for example? Older tutorials achieves this with user.username' or user.get('username') but it seems to be that this doesn't work anymore?
I created a fiddle: http://jsfiddle.net/3zGsC/4/ (line 21/22)
After submitting the form the username should be written to the console, but its undefined.
Basically problem is that you are trying to access properties before model is resolved. You can use then method to wait for model resolution
here is a fiddle: http://jsfiddle.net/3zGsC/5/
this.store.find('user', 1).then(
function(resolveduser) {
console.log(resolveduser.get('username')+' from then');
}
);