1👍
Finally I found where was the issues.
when I was trying with
graph = GraphAPI(token_app)
I was on the good way, the only things to do was to delete
access_token= token_app
the token is saved when at the instruction GraphAPI(token_app) so there is no need to give it again.
The correct code is :
@facebook_authorization_required
@csrf_exempt
def notify_self(request):
token = request.facebook.user.oauth_token.token #user token
token_app=facepy.utils.get_application_access_token('APP_ID','APP_SECRET_ID')
graph = GraphAPI(token)
graph.post(
path = 'me/notifications',
template = '#Text of the notification',
href = 'URL',
access_token= token_app
)
return HttpResponse('<script type=\'text/javascript\'>top.location.href = \'URL\'</script>')
Hope that will help someone
0👍
When creating notifications, you should use the app token, not the user token. So, the token = … line is not necessary.
In addition, since you are using an app token rather than an user token, you cannot use “me/…” in the path; you must specify the user ID.
This is what worked for me:
@facebook_authorization_required
@csrf_exempt
def notify_self(request):
token_app = facepy.utils.get_application_access_token(
settings.FACEBOOK_APPLICATION_ID,
settings.FACEBOOK_APPLICATION_SECRET_KEY
)
graph = GraphAPI(token_app)
graph.post(
path='%s/notifications' % request.facebook.user.facebook_id,
template='#Text of the notification',
href='my targe URL',
)
return 'etc'
- [Django]-Config Django 1.5.1 for aptana studio 3
- [Django]-How do I programmatically create a user with django_social_auth?
- [Django]-ElasticSearch term suggest on analyzed field returns no suggestions
0👍
Jiloko Has forgotten to update the code, I tried the code and the correct code is here:
@facebook_authorization_required
@csrf_exempt
def notify_self(request):
token_app=facepy.utils.get_application_access_token('APP_ID','APP_SECRET_ID')
graph = GraphAPI(token_app)
graph.post(
path = 'me/notifications',
template = '#Text of the notification',
href = 'URL'
)
return HttpResponse('<script type=\'text/javascript\'>top.location.href = \'URL\'</script>')
you can change ‘me/notifications’ for ‘USER_ID/notifications’
- [Django]-Prefetch_related() join all on first item
- [Django]-Django Postgresql syncdb error
- [Django]-Django aggregation over annotated query
- [Django]-Django List deserialization in rest-framework