Rails: How to post on my main facebook page through API? - ruby

I have the following permissions:
create_note, email, offline_access, photo_upload, publish_stream, read_stream, share_item, status_update, manage_notifications, read_friendlists, video_upload, user_relationships, user_status, user_photos
I can do post on the user timeline (www.facebook.com/username) but I can't see how to post on the user's wall (www.facebook.com)
To post on the user timeline, I use a code something like:
if I need to attach an image to the post
client.put_connections("me", "feed", attachments, attachments)
and
if I don't need to attach an image to the post
client.put_connections("me", "links", attachments, attachments)
both are working nice, but none of them really publish the message on the wall (www.facebook.com as a logged in user)
So, I just wondering if it is a normal behaviour or am I just missing something?
Thank you.

The same behavior I can see for other users those are sharing update from API. I think it's normal and we need not to worry about it.
As per me : We can't not say this is required because getting our own feed in 'News Feed' section is not beneficial at all.

Related

How do I use a webhook using an existing bot with discord.py

I am trying to make a webhook where when a specific yt user posts a video I want my bot to post an emded link and text, however the catch is I am trying to add this to an existing discord.py bot that does other functions. I am using 'If this then that' to create the webhook but I don't know URL to use on this page in the Then That section. Am I doing it wrong? Does anyone know how to do this?
Thanks
Maybe try this:
import requests
discord_webhook_url = 'webhook url'
Message = {
"content": "some stuff here"
}
requests.post(discord_webhook_url, data=Message)

The like-button show my like-count, but it's not visible in the facebook api

If i go to https://developers.facebook.com/docs/plugins/like-button/ and enter https://www.ballantinesbarproject.fr/?name=epicerie and select box-count as layout.
the like-button shows a like count, as expected, since I liked the page. However, if I look in facebook api:
REST:
https://api.facebook.com/method/links.getStats?urls=https://ballantinesbarproject.fr/?name=epicerie&format=json
FQL:
https://graph.facebook.com/fql?q=select%20url,%20like_count%20from%20link_stat%20where%20url=%22https://ballantinesbarproject.fr/?name=charlatan%22
(though one user claims, he can se counts in the fql-api)
It says there is 0 likes. How come?
Following query is the proper FQL Query for retrieving like or comments count for a link
select url, like_count from link_stat where url="https://ballentines.herokuapp.com/?name=charlatan"
I have debugged the above Query with Graph Explorer
Reference : https://developers.facebook.com/tools/explorer/145634995501895/?fql=SELECT%20like_count%20FROM%20link_stat%20WHERE%20url%20%3D%20%27https%3A%2F%2Fballentines.herokuapp.com%2F%3Fname%3Dcharlatan%27
If you check on above link, you would get proper like_count (now 3). Screenshot below
If you check above Screenshot the application selected is "Graph API Explorer" which is the default App while debugging with Graph API explorer.
If you are logged in with your proper Developer Account. the application Dropdown would also have your Application.
So after switching to your Application, click "Get App Token" and then submit the Query.
Now the like_count would come 0 for the same query. See Below Screenshot.
Now click on "Get Access Token", this would ask you to Allow the App if you not already done so. After "Allow App" proper User Access Token would be loaded in "Access token" box and now again Submit your Query. Now the "like_count" would be 3 as expected.
So you would need proper User Access Token to retrieve proper information from "link_stat" FQL table and App access token wont work for it
Hope this helps.
I guess you should use the following FQL:
select url, like_count from link_stat where url="https://ballentines.herokuapp.com/?name=charlatan"
Gives me
{
"data": [
{
"url": "https://ballentines.herokuapp.com/?name=charlatan",
"like_count": 1
}
]
}
as result...
The Open Graph debugger shows that the og:type meta-data is missing. That could be related to the problem. Can you add it?
https://developers.facebook.com/tools/debug/og/object?q=https%3A%2F%2Fwww.ballantinesbarproject.fr%2F%3Fname%3Depicerie

How to handle every request in a Firefox extension?

I'm trying to capture and handle every single request a web page, or a plugin in it is about to make.
For example, if you open the console, and enable Net logging, when a HTTP request is about to be sent, console shows it there.
I want to capture every link and call my function even when a video is loaded by flash player (which is logged in console also, if it is http).
Can anyone guide me what I should do, or where I should get started?
Edit: I want to be able to cancel the request and handle it my way if needed.
You can use the Jetpack SDK to get most of what you need, I believe. If you register to system events and listen for http-on-modify-request, you can use the nsIHttpChannel methods to modify the response and request
let { Ci } = require('chrome');
let { on } = require('sdk/system/events');
let { newURI } = require('sdk/url/utils');
on('http-on-modify-request', function ({subject, type, data}) {
if (/google/.test(subject.URI.spec)) {
subject.QueryInterface(Ci.nsIHttpChannel);
subject.redirectTo(newURI('http://mozilla.org'));
}
});
Additional info, "Intercepting Page Loads"
non sdk version and with much much more control and detail:
this allows you too look at the flags so you can only watch LOAD_DOCUMENT_URI which is frames and main window. main window is always LOAD_INITIAL_DOCUMENT_URI
https://github.com/Noitidart/demo-on-http-examine
https://github.com/Noitidart/demo-nsITraceableChannel - in this one you can see the source before it is parsed by the browser
in these examples you see how to get the contentWindow and browserWindow from the subject as well, you can apply this to sdk example, just use the "subject"
also i prefer to use http-on-examine-response, even in sdk version. because otherwise you will see all the pages it redirects FROM, not the final redirect TO. say a url blah.com redirects you to blah.com/1 and then blah.com/2
only blah.com/2 has a document, so on modify you see blah.com and blah.com/1, they will have flags LOAD_REPLACE, typically they redirect right away so the document never shows, if it is a timed redirect you will see the document and will also see LOAD_INITIAL_DOCUMENT_URI flag, im guessing i havent experienced it myself

What's the correct way to listen for a Google+ Hangout state change?

The Hangout API at https://developers.google.com/+/hangouts/writing includes an example to set a callback function when the hangout state has changed, like this:
gapi.hangout.onStateChanged.add(onStateChange);
When run, this results in an error similar to "gapi.hangout.onStateChanged is undefined". A quick check in Firebug shows that the onStateChanged method belongs to gapi.hangout.data not gapi.hangout.
What is the correct way to add a callback function when the state has changed?
The method that you're looking for is indeed a member of gapi.hangout.data. The writing article you mention seems to be out of date. I fix it :)
To do something when state changes just attach a callback:
gapi.hangout.data.onStateChanged.add(function() {
console.log(gapi.hangout.data.getState());
});
You can find working examples of the code in action on the sample apps page.

Is it possible to post a comment to an existing Event using php-sdk?

I'm able to create and delete events, but haven't found where to post follow-up comments to events.
So, is it even possible to post a comment to an existing event, created by my application, using php-sdk?
I am assuming that you meant "make a post on a event wall" because you can not comment events in Facebook. You can use the PHP SDK (see on github) to make any call on the graph API, including posting on an event wall.
You need for that the access token of your application (see how to get it in the Facebook reference) and the ID of the event (EVENT_ID). And then :
require "facebook.php";
$facebook = new Facebook(
'appId' => YOUR_APP_ID,
'secret' => YOUR_APP_SECRET,
);
$facebook->setAccessToken(YOUR_APP_TOKEN);
$args['message'] = "Hello world !";
$facebook->api('/EVENT_ID/feed', $args);
More on publishing post in the Facebook graph API Documentation.
Hope that helps !

Resources