I am uploading photos through my app, and the photos are being successfully uploaded to the logged-in user's Photos section. However, some users are not getting their photo to be posted on their timeline. Is there an account setting that is causing this? Is there another object variable I can pass to ensure it gets "shared" when it's uploaded?
EDIT: It appears that the images went into "Pending approval" status - is there a way to bypass this?
Thanks in advance.
var file_name = 'http://their-image.com/image.jpg';
var access_token = FB.getAuthResponse()['accessToken'];
FB.api('/me/photos', 'post',{
message: "The image message.",
url: file_name
},
function(response){
if (!response || response.error) {
alert('Error occurred');
} else {
alert('Your photo was posted!');
}
}
);
I have found the issue. Some user settings require that you must Approve any photos uploaded by a Facebook App. So the photo is being added, but it is sitting in "pending" under the user's Album for the app.
Here is a code-bit that will help you get the link to your app's album, so the user can view their photos that are awaiting approval.
FB.api('/me/albums', function(response) {
// console.log(albums);
var albums = response['data'];
for (var key in albums) {
var album = albums[key];
if (album['name'] == 'You App Name's Photos') {
alert(album['link'];
}
}
});
Related
I have a django app where users can save their contacts. I am not building a flow to allow users to download their contacts locally.
To do so, I built a CTA ("download") that if clicked
Gets the id of the contact selected
Triggers an Ajax request to my views
In the view I get the contact id, retrieve the data from my DB and create a VCF card out of it. (A contact card - basically a text file)
Now I would like to have such file downloaded on the client's machine but I don't know how to do it.
I managed to do it if I redirect to a new url where the view does exactly what my view below does, I want to allow users to download the file without being redirected to a new page. Also, trying to avoid storing the contact ids in the URL.
That's why I am trying to use ajax but I think that's creating problems because and Ajax request waits JsonReponse from the view.
I tried both a GET or POST but it's not working.
This is my view currently:
def get(self, request, *args, **kwargs):
#Get the ids
ids = request.GET.getlist('contact_ids[]')
# Get contqacts associated with ids
contacts = Contact.objects.filter(id__in=ids)
# Transform contacts into long text
text = Vcard().GroupVcards(contacts)
#Create file on the fly and attach it to the response (is this correct actually?)
response = HttpResponse(content_type='text/plain')
response['Content-Disposition'] = 'attachment;filename=ven.vcf'
response.writelines(text)
#return
return response
This is the Jquery triggering the ajax
$('.Vcard').on('click', function(e) {
let id = $(this).data('contact_id')
$.ajax({
type: "GET",
url: Urls['action:DownloadContact'](),
data: {
csrfmiddlewaretoken: csrftoken,
'contact_ids': [id],
},
error: function(response){
console.log(response)
console.log('error')
},
success: function(response) {
console.log(response)
console.log('success')
}
});
})
I have created an app with react native, where the user is able to log in with facebook. I request the users first_name, last_name and picture.width(520)(which is the users profile picture).
When the user log ins for the first time it works fine. In the profile section you can actually see the picture, however after a day or so if you log in again the profile picture wont load. In the database I can still see the same URL given to me by the request, it just wont load.
Does FB change the URL or how can I permanently get a URL that points to the users profile picture?
The actual request:
const infoRequest = new GraphRequest('/me',
{
parameters: {
fields: {
string: 'first_name,last_name,picture.width(520)'
}
}
}, (error, result) => {
//save picture URL to database
})
I have an app cloned from the flasky app.
I have added the Google sign-in button to the login page, which sends a POST message with token details. So flasky renders a login form, but instead of the form doing POST, Google's javascript does.
I can see that the token is correctly read by my handler:
#auth.route('/receive_idtoken', methods=['POST']) # gives us the idtoken.
def receive_idtoken():
it then goes on to check that the user is known:
user = User.query.filter_by(email=idinfo['email']).first()
if user is not None:
login_user(user,remember=True)
flash("Congratulations, you have logged in")
return redirect(request.args.get('next') or url_for('main.index'))
The redirect causes my debugger to resume control in the handler for main.index and template renders fine. But the page never appears in the browser. The login page stays. The browser is Firefox, all on ubuntu 16.04
I guess the previous request was not terminated by the ajax post of the token?
this is how the token_id is posted:
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://localhost:5000/auth/receive_idtoken'); // to-do need to use the template for this so not to hardcode
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
console.log('Signed in as: ' + xhr.responseText);
};
xhr.send('idtoken=' + id_token);
(Newby)
I simply don't know how to do it.
I have an html linked with a knew url, with two buttons.
imagine that url is only shared with two persons/users.
each person have to push the button signed their name.
I tried using request, but I couldn't figure out how to know if more than one user is active in that view.
The another point is:
One person reach the url first, how to make an "refresh" in their browser, when the second one appear?
You'd have to store who's at what view in some model.
class UsersInURL(models.Model):
users = models.ManyToManyField(User)
url = models.CharField()
# you'd probably want to use a through table and set up some expiration logic
Then remember to modify this model every time a logged in user views a page; middleware sounds perfect for this.
class UserTrackerMiddleware(object):
def process_view(self, request, *args, **kwargs):
UsersInURL.users.through.filter(user=request.user).delete()
users_in_url, created = UsersInURL.objects.get_or_create(url=request.path)
users_in_url.users.add(request.user)
Then to refresh their page, you'd need to set some kind of communication between the server and the browser which pings this model and refreshes if it detects some change.
var lastCheckedUsers = undefined;
function checkForNewUsers() {
$.get('/some-ajaxy-url/', { url: document.URL }, success: function(data) {
// you'd have to set up a view that returns active users # url
if (lastCheckedUsers != data.users && lastCheckedUsers != undefined) {
window.location.href = window.location.href;
};
lastCheckedUsers = data.users; // store last state; refresh if modified.
})
};
setInterval(checkForNewUsers, 1000);
I'm sure that should get some ideas flowing.
I am trying to post to Facebook Group Wall via Graph API. When i make the post, owner of the post is set as my personal id. Would someone know how to make Group has the owner of the post. Below is my current code:
form_fields = {
"message": 'This is message title',
"link": 'http://facebook.com',
"name": 'This is message title',
"access_token": 'token here'
}
form_fields['description'] = 'This is message body'
form_data = urllib.urlencode(form_fields)
response = urlfetch.fetch( url="https://graph.facebook.com/%s/feed" % group_id,
payload=form_data,
method=urlfetch.POST,
deadline=10
)
You can't do it. That's one of the differences between the group and pages, in a page when you do a post as an admin the user of the post is the page and not your userid, so there is no way that you can make a group to be the owner of a post using the Graph api. See this link http://www.facebook.com/help/?page=904 and search the question "How are Pages different from Groups?".