I have a project where I need users to share content via app.
After that I will need to track how many shares were made per day.
Now I can share a link using three different functions as follow:
FB.ui({
method: 'share',
href: 'https://developers.facebook.com/docs/',
hashtag: '#myhash',
}, function(response){console.log(response)});
FB.ui({
method: 'share_open_graph',
action_type: 'og.likes',
action_properties: JSON.stringify({
object:'https://developers.facebook.com/docs/javascript/examples',
})
}, function(response){
// Debug response (optional)
console.log(response);
});
FB.ui({
method: 'feed',
link: 'https://developers.facebook.com/docs/',
ref: 'ref1, ref2'
}, function(response){console.log(response)});
The only differences I can see is that using share I can add hashtags and feed dialog I can add refs. Visually they all look the same on the feed...
Will any of these be more benefitial than the others assuming later I want to search and analyse the shared content? (for example, different hashtags and / or different sources like mobile / web)?
Related
I have created a web app in which page which consist of choose file input and Now I need to preprocess the data with one button and that preprocessed data should be used for next button called forecast to show the result in that page.Is it possible with Django.
Does it compulsory to take any action in page with url changes in django?
The question is not completely clear, but from what I understand you can use Ajax. On first button click send an ajax request, process it in the view logic, send the appropriate data using maybe JsonResponse, and in the success block of your ajax request set the appropriate data for your forecast button using jquery. Something like -
$.ajax({
url: <url_of_data_processing_logic>,
type: 'post',
data: <required data>,
dataType: 'json',
success: function (data) {
$("#<forecast_button_Id>").html(data.forecast_html);
},
error: function (e) {
console.log(e);
}
});
I need to have SKU in product list in admin panel "OC3.0.2.0" and if that possible to have it in filter at same place. Is here anybody can show me the way to solve this small problem.
Thanks a lot for your time.
You need to modify controller, language, model and template files to add SKU filter in admin product list page, where its lengthy process.
I just modified this pages but can paste the whole code here because code is more than 30000 characters. I created a zip file with modified files.
If you are using default theme please download this files from this link and replace the default files with new files
If you are using a customized theme you can download the extension from this link.
Note: If SKU is not Mandatory then please remove the autocomplete from the product list. Otherwise, it creates displays empty fields in its column.
Please Open product_list.twig from admin/view/template/catalog
and remove the following code from it
$('input[name=\'filter_sku\']').autocomplete({
'source': function(request, response) {
$.ajax({
url: 'index.php?route=catalog/product/autocomplete&user_token={{ user_token }}&filter_sku=' + encodeURIComponent(request),
dataType: 'json',
success: function(json) {
response($.map(json, function(item) {
return {
label: item['sku'],
value: item['product_id']
}
}));
}
});
},
'select': function(item) {
$('input[name=\'filter_sku\']').val(item['label']);
}
});
Hope this helps you
I created a free extension for this to help the community. Here is the link:
https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=38074
Designed to work for Opencart 3.x version.
This is probably a silly question, but I can't find an obvious response.
I'm developing a web application using (Geo)Django for the backend and Leaflet, among others, for the frontend. My point is I want to make a url call from my JS code to my Django backend. Something like this:
$.ajax({
type: 'POST',
url: '<A_URL_HERE>',
data: {"data":<MY_JSON_DATA>},
dataType: 'json',
success: function(responseData, textStatus, jqXHR) {
console.log("Data saved");
},
error: function (responseData, textStatus, errorThrown) {
console.log("Problem saving the data");
}
});
My problem is with the url. I know that cool URIs don't change, but for example, if I want to keep different dev/test/prod environments without changing that parameter, how should I do it? In the backend part, I'm following good practices for this kind of problems, but I have short experience with JS and frontend.
Many thanks in advance
Two possible solutions:
Use dynamically generated JavaScript, i.e. the JavaScript file is not a hardcoded static file. Instead it is a template which backend populates with variables (in particular URL);
Similar to the one above except that JavaScript is a hardcoded static file and for example you put your URLs in base HTML (which is generated from a template on the server side):
base.html
<script>window.urls = { "my_url": "{{ my_url }}" };</script>
my_script.js
$.ajax({
url: window.urls.my_url,
...
});
With this you can generate URLs based on you server settings.
I have the following Facebook Graph API call:
FB.ui({
method: "send",
to: '123123,456456',
name: 'People Argue Just to Win',
link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html'
}, function(response) {
// some stuff
});
Whenever it's invoked, my message's only recipient is the user with id 123123. If I switch the two numbers, the 456456 is the sole recipient.
As far as I can tell, I'm using the API exactly like I'm supposed to, so what could I be doing wrong?
It looks like it's not possible with the send method to specify multiple recipients: http://bugs.developers.facebook.net/show_bug.cgi?id=18806
It does look like it can be done with the apprequests method, though:
FB.ui({
method: 'apprequests',
message: 'My message',
data: {},
title: "My Title",
to: [123123, 456456]
});
For my purposes, that's close enough.
I am not familiar with using Facebook Javascript SDK.
My story is when I access to the website It displays all my friends(pic and name) on a webpage.
I registered Facebook API and App ID
I put website URL as http://localhost:81/ because I am testing my own local machine.
Do you have any good example website or good examples?
Please share with me
Thank you.
First your app should use required permissions like,
user_birthday, friends_birthday, user_location , friends_location...
( for more permissions)
Get info about current user:
FB.api('/me', function(response) {
// Stuff here
});
Get info about current user's friends:
FB.api('/me/friends', function(response) {
// Stuff here
});
you will get the response like,
{data: [{id: "FRIEND1_ID", name: "FRIEND1_NAME"}, {id: "FRIEND2_ID", name: "FRIEND2_NAME"}]....}
If you want get some more properties of your friends, use FIELDS parameter, like
FB.api('/me/friends', {fields: 'name,id,location,birthday'}, function(response) {
// Stuff here
});
If want to get individual user's friend info:
FB.api('/FRIEND1_ID', function(response) {
// Stuff here
});
Try this Example Site
Direct Access Method:
Log into Facebook under your name. If you need an "Access Token", Click on the Extended Permissions and click the "read_friendlist" check box to get your Access Token and then
submit your query. You may need to "Allow" access, so just follow the prompts given.
Voila! You now have the usernames for everyone on your Friends List. The "username" parameter in the query will give you the contact email "message to that person" and you append #facebook.com and send them a message. Very simple.
http://developers.facebook.com/tools/explorer?fql=SELECT%20username%20FROM%20user%20WHERE%20uid%20IN%20%28SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%20%3D%20me%28%29%29%20ORDER%20BY%20name
-SAB