RestFB get Reactions on a Url - restfb

I see that RestFB has added access to Reactions in the Post, Photo and Video objects, but it does not seem to have access from a Url. What would be the best way to get the Reactions on a Url? Do I need to call the Graph API directly?

RestFB does not support reactions on open graph objects. So you should call the opengraph id as you mentioned in the comment above and work with the fetchConnection call. As Type you should use Reactions.ReactionItem.
Connection<Reactions.ReactionItem> con =
client.fetchConnection("<ogid>/reactions", Reactions.ReactionItem.class);
I think this should work. The code is untested ;)

Related

How to mention a user mentioned in the command discord js

So im working on a discord bot, and working on a command where it mentions a user. For example: -fakekick #user and the bot would say User has been kicked I've read through the docs and found a few sites but I couldn't really understand it as I just started discord js a few days ago. Thanks
To get the user object of a mentioned user, you can very simply use the mentions extension of the message object. We can very simply use it in order to define our user, and later on, mention him in a future message. That can be done very simply as so:
const user = message.mentions.users.first(); // Would get the first mentioned user's object
message.channel.send(`${user} has been kicked!`); // To mention a user, you simply need to mention his user object.

Use query string in URL or use multiple URL?

If I want to display many posts in my web application but every post have its own type and I want to display each type in single page so, What's the best method to do that? Is put all all posts in one url and use query string to filter the posts upon the type and display it in the page?
For example : axios.get('/posts?type =sport')
Or I have to put every single type in separate Url
For example: axios.get('/posts/sport')
Also one more question please?
use one reducer to manage every posts or create one reducer for each post type?
you can add a dynamic route to every new type.
Ex:
'/transaction' -> component-1
'/transaction/:type' -> component-any (multiple)
welcome to Stackoverflow!
I can imagine you have a web API of some sort serving a URL /posts. You want to consume that endpoint from your web application, and you are using axios to do that. I can assume you are using JSON to return that data. Correct me if I'm wrong.
Now that the basic information is "clear", what data you serve from the endpoint, and how it is requested from the client is up to you. Do you want to ask the server what types are there first, and then do one AJAX request per type? Ok. Do you want to serve all posts independent of their type? Ok. Do you want to accept POST data in your controller so you can filter the results before returning a response? Ok.
If you are looking for a more specific answer, you must give more details, or specify more. But I hope I could be of help.
Edit: complete answer.
If you want to filter the results, you have to send some additional data in your POST request, in this case, your post type. In axios, this could be done like this:
axios.post('https://example.com/posts', {
type: 'sports'
}).then((data) => {
console.log(data);
});
You can obviously get the "type" value from a select input, other variable, even the current router page. I don't know your exact setup, but you can always come back and ask ;)
THEN, in your API controller you have to get that POST parameter type, and use it to filter the results. Again, I don't know your exact setup, but for MySQL if would be a WHERE statement in your query, or similar.

Complete solution

I use the <NotificationDropdown notify /> React component to get rendender a notification feed, but when I create comment, like or post reactions, the notification feed stays empty. Please help me solution this problem.
Reactions by default don't get posted to any feed. They are only attached to the activity. If you want to post an activity to a feed when creating a reaction you need to use the targetFeeds.
So in your case you probably want to do something like:
client.reactions.add(
"like",
activity.id,
{},
{targetFeeds: ["notification:" + activity.actor.id]
)

Watson Dialog does not recognize continuation of conversation

When trying to use the Dialog tool to get a feel for how the APIs work, I ran into a problem where a POST to /conversation creates a new conversation, instead of continuing an existing one. I am using the docs found at : http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/dialog/api/v1/
An initial POST returns a conversation and client id, but subsequent requests with those values added, along with an input value, just return information for a new conversation. Are these docs inaccurate?
Here is a screenshot from one of my many attempts at getting this to work. The client and connection IDs are from a previous POST to /conversation
http://imgur.com/4035dWe
Thanks for your help!
Your first call to Converse you should not specify the conversation ID. Dialog will return a conversation ID with the first response.
You then use that ID going forward to maintain the conversation. It is unclear if you are doing this in the example above.
It turns out I was using the incorrect encoding for the conversation / client ID's and input. Watson expects the form values to be URL encoded. Once I made that change, the problem was resolved.
Thanks to everyone who offered their time and help!

Redrawing endpoints using jsPlumb

I have been stuck with this a few days and want your help to know how to tackle this problem.
I created this application something like a flowchart to draw different types of plumb items with different endpoints attached to them. After it is being created as an element the endpoints are added dynamically according to the type of plumb item. is it like the following.
This is how I create the plumb items.
var element = document.createElement("div");
element.setAttribute("id",schema_id);
element.setAttribute("class","item " +control.Type);
element.setAttribute("style","left:" +posX + "px ; top: "+posY+"px");
var output = document.getElementById('container');
output.appendChild(element);
And then I add the endpoints according to its type.
jsPlumb.addEndpoint(element,<the style goes here>,{ anchor:<the location of the endpoint goes here>, uuid: <a new ID is created for this>});
And this is what it looks like
Screen One
I managed to grabbed the data from the method "GetConnections" and get it saved in the DB as a JSON. This JSON includes all the IDs which are for plumb items and all the endpoints.
But when I try to retrieve it back again to the UI, it appears like this. Everything appears great except the endpoints.
Screen Two
On redraw, the endpoints are created in the same way mentioned above. To reconnect the endpoints I am using this code.
jsPlumb.connect({ source:<source id>, target:<target id>,anchors:<location of the endpoint>,<style>);
The problem :
For the above code, Although I give the UUID of the endpoint to the source and target, it doesn't identify it as endpoints to connect from and to.
Is there a way to find the ID and get them connected? What I found out was that only the plumb items could be searched with "getElementById" with the UUID but not the endpoints.
The problem is how to make these endpoints get connected as originally drawn. How can connect each endpoint back again? I have all the IDs and when they are redrawn they are having the same IDs as it had when it was saved. But I couldn't find a way to connect the endpoints back again separately since this has different types of endpoints specific to each plumb item.
Any suggestions?
Sorry for the long post
Thank you in advance!!
Please see the connect method
If you connect ids, or elements, or Endpoints use
jsPlumb.connect({source:<source id>, target:<target id>});
but if you connect array of UUIDs of the two Endpoints use
jsPlumb.connect({uuids:<array of uuids>});

Resources