Hello i am trying to get the users tagged photos one at the time with javascript.
Here is how i call it:
FB.api('/me?fields=name,picture.type(large),photos.limit(2).type(tagged)', function(response) {
play(response.name, response.picture.data.url, response.photos.data.source);
....
And how i use them:
use: {url: "some url....", params: ['name','fb','photo1', 'photo2']},
The thing is that when i call this i get "Cannot read property 'data' of undefined "
on the photos.limit(2).type(tagged)
The other things work great. Name and profile pic.
Any ideas?
Perhaps i need to sort the results from photos.limit(2).type(tagged) or something but i have no clue o how to do that...
Any help will be awesome.
Thanx
Sounds like you aren't getting any data from the photos endpoint.
Ensure that you have user_photos permission in
FB.login(function(response) {
// handle the response
}, {scope: 'user_photos'});
Related
I'm trying to make a web application using Outlook API's that allows me to search for a specific Outlook contact by his name.
I've got a little knowledge of javaScript but i never used any API or manipulated JSON files beforehand, so i looked through tutorials to help me, and
I ran into this one : https://dev.outlook.com/restapi/tutorial/javascript which i followed and succeeded to implement without much trouble.
Briefly, the tutorial allows me to build an app that can display the last 10 emails from the user, or the contact list of this user, which gives something like that :
Contacts displayed
Now what i'm trying to do is to filter this display and be able to search something like " give the contacts which name contains the syllable "AG" ".
I tried to understand the code as much as i can and i'm almost sure that i have to modify the function displaying all the contacts.
So what i did is that i pasted it, renamed it but now i'm struggling with the query parameters.
function getUserContacts(emailAddress, callback) {
getAccessToken(function(accessToken) {
if (accessToken) {
// Call the Outlook API
var callOptions = {
// Get contacts
url: apiEndpoint + '/Me/contacts',
token: accessToken,
method: 'GET',
email: emailAddress,
query: {
// Limit to the first 100 contacts
'$top': 100,
// Only return fields we will use
'$select': 'GivenName,Surname,EmailAddresses',
// Sort by given name alphabetically
'$orderby': 'GivenName ASC'
}
};
makeApiCall(callOptions, function(result, error) {
if (error) {
callback(null, error);
} else {
callback(result.value);
}
});
} else {
var error = { responseText: 'Could not retrieve access token' };
callback(null, error);
}
});
}
And that's the moment i get totally lost, i tried adding '$where':GivenName='AG' in the query{} section, as well as '$filter':GivenName='AG', but neither of them worked. I searched online for an answer but in every one i founded, the JSON file was "available" ( meaning for me that they have,somewhere this kind of code :
[
{"name":"Lenovo Thinkpad 41A4298","website":"google222"},
{"name":"Lenovo Thinkpad 41A2222","website":"google"}
]
But i don't have this type of code anywhere, so i'm wondering if it is possible to do it like i tried to, or if i have to find a way to retrieve the JSON file in order to obtain something like just above ?
I hope i've been clear enough despite my lack of experience in this field, i'd be glad to give some more details/codes if you ask too !
Thanks in advance and have a great day :)
Thanks to Useless Code and his link i managed to send the right request (error was coming from the fact that filter properties must be listed first in the orderby) from the outlook sandbox and get the expected answer with this URL:
https://outlook.office.com/api/v2.0/me/contacts?$filter=GivenName eq 'AG-Carto'&$orderby=GivenName ASC&$select=GivenName,Surname,EmailAddresses
Now what i'm trying to do is to get my javascript code to send it right.
So i know i have to modify the query{} part of the function, i tried this :
query: {
'$filter': 'GivenName eq AG-carto',
'$orderby': 'GivenName ASC',
'$select': 'GivenName,Surname,EmailAddresses'
}
But when i run it, i got a bad request error, and i see that the url sent by the js code is this one :
https://outlook.office.com/api/v2.0/Me/contacts?%24filter=GivenName+eq+AG-carto&%24orderby=GivenName+ASC&%24select=GivenName%2CSurname%2CEmailAddresses
So i'm obviously seeing that they aren't the same, and i have no idea on how to modify the query{} section so that the URL sent by js is the same as my working URL. If anyone could help me on that i'd be grateful !
I'm having a little problem figuring out how to follow, like retweet someone's tweet.
As you can probably see I can get all tweet's mentioning justinbieber but i want to be able to put somecode in the function to either retweet or like the status or even follow the user that tweeted it.
If you managed to understand all of that jumble I'd appreciate the help!
What stream.on(...) does is call the function in the second parameter every time a tweet comes up, and it passes the tweet itself as a parameter. So every action you want to do with that tweet, you need to do it in the function.
To see all information on the tweet object you can go on the Twitter API page. You have access to all of this in your anonymous function !
For retweeting every tweet :
...
stream.on('tweet', function(tweet) {
T.post('statuses/retweet/:id', { id: tweet.id_str }, function (err, data, response) {
console.log(data)
})
})
Syntax taken from twit module documentation
First time answering, I hope this helps.
I'm newbie using parse.com I watched a video tutorial very useful, and now I'm doing my first app. But apparently I think I'm doing something wrong:
I have a Class called MyClass that includes a use. I added a row. In my javascript code I try a simple query by objectId but I'm getting empty results:
var MyClass = Parse.Object.extend("MyClass");
var query = new Parse.Query(MyClass);
query.equalTo("objectId","kX6lNWOpPs");
query.include("user");
query.find({
success: function(results){
console.log("query ok!");
console.log(results);
},
error: function(error){
console.log(error);
}
});
It looks that simple that I'm not sure if I'm doing a huge mistake. The result in the console is:
query ok!
[]
In my class there's a row for sure. I've refreshed the site, even logged out in parse.com. Also the ID is correct, verified a lot of times.
The funny part is that in the video tutorial we used the exact same code, with different classes and data, but same structure.
Thanks in advance for any help. :)
EDIT: if I remove the equalTo and the include functions the results are the same.
EDIT 2: My error was different. I'm ashamed about it :S I had a typo in the Class name: I was using PlayerKey instead of PlayerKeys. The full name doesn't fit on the sidebar column. One of those stupid errors that make you crazy. Besides Parse didn't told me that the class doesn't exists or create it on the query, that only happens as far as I know when you extend. As I said, I'm so newbie :)
If you have the object id then you don't need to run a query as such, you can just get the object with the query:
query.get("kX6lNWOpPs", {
success: function(obj) {
console.log("query ok!");
console.log(obj.id);
},
error: function(object, error) {
console.log(error);
}
});
Note that to use include the user column should be of Pointer type.
I have read many Twitter & jQuery questions on here but none seem to answer my question. I am simply trying to grab 5 "tweets" from a public user. I am not doing anything with the data at this step, but my callback function never fires.
$.getJSON("https://api.twitter.com/1.1/statuses/user_timeline.json?callback=?",
{
screen_name: 'dojo',
count: '5'
},
function (data) {
alert("IT WORKED!");
});
Here is the same code on jsFiddle
Thank you for your help
That isn't going to work because Twitter has now required that you authenticate in order to fetch tweets for a given user.
Reference: https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline Look at 'Authentication' info.
You'll want to use a library to help get an oauth signature and make the request.
i'd like to know how to fetch articles that friends have read from a Facebook app. I use the following query to get articles that I have read:
/me/news.reads
But i want all the articles that friends have read, is that possible?
It is not an apt solution but you can do is loop through facebook id's of your friends and for each friend's Id get all the news read as /$friend_id/news:reads
I dont think there is any direct api function to get action performed by friends.
Try this
FB.api('/me/friends', { 'fields' : 'name,news.reads.limit(10)' }, function (data) {
// if(!data || data.error) { }
// console.log(data);
});
You can omit the limit if you like, or add more fields. Of course this would also work as a GET request to: http://graph.facebook.com/me/friends?fields=name,news.reads.limit(10)&access_token=XXXX