I want to post a story from my application about other user. I want to get a story with link to profile like this http://prntscr.com/def3b6.
I use OpenGraph Object: profile. I writed tags: profile:first_name, profile:username, profile:gender, profile:last_name, fb:profile_id.
I got this: http://prntscr.com/def3l4
What am I doing wrong?
Related
So, i have this problem when im trying to create my "company", when i didnt have user authentication the view worked just fine. Now i've added django allauth, and this screen appears to me:
enter image description here
So i will leave here my model and my view to create the company
Im just a begginner so sry for my bad explanation
enter image description here
enter image description here
The URLS : https://prnt.sc/K-lKvmfuQtvR
It looks like the problem is with the way your url is setup. Do you have a screenshot of the urls.py as well so we can see how you setup your url mapping. (OP added this screenshot: prnt.sc/K-lKvmfuQtvR)
Your companies/<pk>/ endpoint is catching your "create_company" value and storing it as a variable. Try moving your companies/create_company path above your companies/<pk>/ like so
path('companies/', listing_companies),
path('companies/create_company/', company_create),
path('companies/<pk>', retrieve_companies),
path('companies/<pk>/update/', company_update),
path('companies/<pk>/delete/', company_delete),
Alternatively rename companies/create_company/ to create_company/ like so
path('companies/', listing_companies),
path('companies/<pk>', retrieve_companies),
path('create_company/', company_create),
path('companies/<pk>/update/', company_update),
path('companies/<pk>/delete/', company_delete),
The end goal in either case is simply to make sure your paths are not capturing your "create_company" and storing it as that variable that it is passing along to your path's method.
I'm posting this because I searched stackoverflow and docs for a long time without finding an answer -- hopefully this helps somebody out.
The question is, for testing purposes, how do I find the URL that's related to admin actions for a specific model?
Admin model urls can all be found by reverse(admin:appname_modelname_*), where * is the action (change, delete, etc). But I couldn't find one for the admin actions, and since I was defining custom actions, I'd like to get the url.
This took a fair bit of digging, I couldn't find anything in the Django docs about it and I ended up having to inspect the source code of a third party library.
Essentially there are 2 URL patterns, one for bulk actions and one for object actions:
Bulk: r'admin/<app_label>/<model_name>/actions/(?P<tool>\\w+)/$'
Object: r'admin/<app_label>/<model_name>/(?P<pk>.+)/actions/(?P<tool>\\w+)/$'
The URL name pattern is <app_label>_<model_name>_actions
Therefore we can reverse the bulk view:
Using args: reverse("admin:<app_label>_<model_name>_actions", args=["foo"])
Using kwargs: reverse("admin:<app_label>_<model_name>_actions", kwargs={"tool": "foo"})
and reverse the object view:
Using args: reverse("admin:<app_label>_<model_name>_actions", args=[1, "foo"])
Using kwargs: reverse("admin:<app_label>_<model_name>_actions", kwargs={"pk": 1, "tool": "foo"})
The URL for all custom actions is reverse(admin:<appname>_<modelname>_changelist), but the action name is specified in the action field of the POST data.
The answer, which is hard to find, is that actions are referenced by reverse(admin:appname_modelname_changelist)
I get shared story feed with graph api.
In The result I have fields like :
type": "photo",
"status_type": "shared_story",
"object_id": "647332045296931"
the object_id is the photo object.
I need the post_id of that photo.
How can I get the post id with graph api from that point ?
Thanks
Using fql get page_story_id(Please refer to https://developers.facebook.com/docs/reference/fql/photo):
Retrieve the page_story_id details:
Access the exact page at www base facebook using this page_story_id(replace underscore with "/posts/"):
The post_id can get via https://graph.facebook.com/420619404634864/feed too:
Or fql:
Updates:
For video, it is easier compare with photo type to find post_id from object_id.
As you can see on the screenshot, concate page id "155483697799865" and object id "4320084459885" with underscore is equal to post_id "155483697799865_4320084459885":
Let's visit the story page using these post_id(Again, replace underscore with "/posts/"):
To be clarify, what i answer is get original post_id for this object id, not post_id of share status.
For example, i share a video from coca-cola fan page, the object id 12345 get from "me/feed" is same with object id 12345 get from "coca-cola/feed", which point to the same video. However, the post_id is different. My answer is help you to find out original story post_id (coca-cola upload a video), not the shared post_id(xxx Shared coca-cola's video)
Cheers
I am implementing social login in my application and I am already getting normal fields as First Name, Last Name on Facebook and LinkedIn... Now I want to get the profile picture. I did it for LinkedIn and it is working perfectly, i can see the URL on the extra fields from the database.
I am trying to do the same with Facebook, as I saw here https://groups.google.com/forum/?fromgroups#!topic/django-social-auth/Mee8H8HhLQk
defining
FACEBOOK_PROFILE_EXTRA_PARAMS = {'fields': 'picture'}
FACEBOOK_EXTRA_DATA = [('profile', 'profile')]
But when i did this, somethings got messed up. I am not able anymore to get the first name and last name in my user table as I was doing before these two lines of code. Does anyone know why this problem is happening?
The picture is under http://graph.facebook.com/<user_id>/picture. The user_id is given by the FacebookBackend.
Im playing a little bit with heavy-client app.
Imagine I have this model:
class Category(models.Model):
name = models.CharField(max_length=30)
color = models.CharField(max_length=9)
Im using knockoutjs (but I guess this is not important). I have a list (observableArray) with categories and I want to create a new category.
I create a new object and I push it to the list. So far so good.
What about saving it on my db? Because I'm using tastypie I can make a POST to '/api/v1/category/' and voilĂ , the new category is on the DB.
Ok, but... I haven't refresh the page, so... if I want to update the new category, how I do it?
I mean, when I retrieve the categories, I can save the ID so I can make a put to '/api/v1/category/id' and save the changes, but... when I create a new category, the DB assign a id to it, but my javascript doesn't know that id yet.
in other words, the workflow is something like:
make a get > push the existing objects (with their ids) on a list > create a new category > push it on the list > save the existing category (the category doesnt have the id on the javacript) > edit the category > How I save the changes?
So, my question is, what's the common path? I thought about sending the category and retrieving the id somehow and assign it to my object on js to be able to modify it later. The problem is that making a POST to the server doesn't return anything.
In the past I did something like that, send the object via post, save it, retrieve it and send it back, on the success method retrieve the id and assign it to the js object.
Thanks!
Tastypie comes with an always_return_data option for Resources.
When always_return_data=True for your Resource, the API always returns the full object event on POST/PUT, so that when you create a new object you can get the created ID on the same request.
You can then just read the response from your AJAX and decode the JSON (i dont know about knockout yet).
see the doc : http://readthedocs.org/docs/django-tastypie/en/latest/resources.html?highlight=always_return_data#always-return-data
Hope this helps