how can i execute facebook ajax link like https://www.facebook.com/ajax/bookmark/groups/leave/?group_id=XXXXXXX (which can only be executed using a mouse click) using PHP. So far i can get all my groups ID via the graph api. Found this outdated code on google: http://bpaste.net/show/76918/
You should do it via Facebook API, instead of mocking AJAX request
$facebook = new Facebook(array(
'appId' => 'YOUR_APP_ID',
'secret' => 'YOUR_APP_SECRET',
));
$feed = $facebook->api('YOUR_GRAPH_API_CALL');
you can use graph api in facebook developper space :
check this and replace your-id by your id:
https://developers.facebook.com/tools/explorer/?method=GET&path=you-id%3Ffields%3Dgroups.fields%28id%29
Related
I use the _embed query with wordpress rest api and it works like this :
sitename/wp-json/wp/v2/posts?_embed
And I get the expected results .
But when I use it with search method it doesn't return me the _embedded version of posts :
sitename/wp-json/wp/v2/search?_embed
How can I use the search rest api with embed ?
I succeeded by ignoring the '/search' service and adding a 'search' url parameter to the '/posts' service
So it would look like this
sitename/wp-json/wp/v2/posts?_embed&search=searchTerm
I'm using the Facebook SDK for .Net http://facebooksdk.net/.
The query I am running against the Facebook API returns a list of posts that a public user has made.
The results for the query return are in plain text.
How do I update the URLs and Hashtags so that they are automatically wrapped in links (a href) so that they can be clicked?
For twitter I've used https://github.com/twitter/twitter-text/tree/master/js
This is my code:
var client = new FacebookClient(ConfigurationManager.AppSettings["appToken"]);
dynamic response = client.Get("somePublicUser?fields=posts.limit(1){message}");
var post = response.posts.data[0].message;
The message content is: "Happy #WorldTheatreDay! \n\nWhat's the best show you've ever seen?"
I'd love to see it be something like: ""Happy #WorldTheatreDay! \n\nWhat's the best show you've ever seen?"
I ended up using the Twitter JavaScript tool: https://github.com/twitter/twitter-text/tree/master/js
And just replacing Twitter's URLs for Facebooks alternate versions.
twttr.txt.autoLink("Click this link http://www.google.com", {
hashtagUrlBase: "https://www.facebook.com/hashtag/",
usernameUrlBase: "https://www.facebook.com/",
listUrlBase: "https://www.facebook.com/"
});
I'm creating interface for my Chromium based application, and I've got a problem. I'd like it to show number of my facebook notifications (these white numbers in red rectangles) directly on my website. Is it possible? I couldn't find nothing about that on google.
It should look like: Patrick have 5 new notifications.
EDIT:
Now I've got this:
$request = new FacebookRequest(
$session,
'GET',
'/{notification-id}'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
how to echo this notification-id on webpage?
Use the Facebook Graph API /user/notifications/ for this: https://developers.facebook.com/docs/graph-api/reference/v2.2/user/notifications
I have created a rest service in a java application . I need to call this rest service on the click of a button in Alfresco Share page . How do i approacj it . Can i directly call the service with the url ?
You can add a custom endpoint to SURF & use the SURF Proxy-Servlet:
Example Flickr Endpoint
share-config-custom.xml:
<alfresco-config>
<config evaluator="string-compare" condition="Remote">
<remote>
<endpoint>
<id>flickr</id>
<name>flickr - unauthenticated access for oembed resolution</name>
<description>Access flickr to resolve URLs to embed presentations.</description>
<connector-id>http</connector-id>
<endpoint-url>http://www.flickr.com/services</endpoint-url>
<identity>none</identity>
</endpoint>
</remote>
</config>
</alfresco-config>
In Browser JS Code just use the flickr endpoint via PROXY, e.g. add a new va PROXY_FLICKR_API :
var PROXY_FLICKR_API = Alfresco.constants.PROXY_URI.replace("/alfresco/", "/flickr/");
Alfresco.util.Ajax.jsonRequest(
{
method: Alfresco.util.Ajax.GET,
url: PROXY_FLICKR_API + "add your concrete URL",
successCallback:
{
...
},
failureCallback:
{
...
}
});
You should add your var PROXY_FLICKR_API JS declaration via SURF Extension mechanism - your target markupid is (more details http://blogs.alfresco.com/wp/developer/2012/05/22/customizing-share-javascript-widget-instantiation-part-1/):
<#markup id="yourid" target="resources" action="after">
Using the php sdk, I check if a user inside a tab likes the corresponding page.
If i put the following code inside index.php and use that page as my page-tab-url,
<?php
require_once("facebook/facebook.php");
// Create our application instance
// (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => '1399475990283166',
'secret' => 'mysercret',
'cookie' => true
));
$signed_request = $facebook->getSignedRequest();
echo $signed_request['page']['liked'];
?>
it outputs '1'.
I would like to achieve this asynchronously instead, so I put the php in a separate file and try to access it using ajax instead
$http.post('/facebook/likes.php').
success(function(data){
console.log(data);
}).error(function(data){
console.log(data);
}
);
This sample is using angular, but what javascript library i'm using probably doesn't matter.
When I access the info with javascript Facebook doesn't seem to get the info that I liked the page. Adding a print_r($facebook); on the page I'm retreiving the same values as if i'm not in a facebook-tab:
(
[sharedSessionID:protected] =>
[appId:protected] => 1399475990283166
[appSecret:protected] => 679fb0ab947c2b98e818f9240bc793da
[user:protected] =>
[signedRequest:protected] =>
[state:protected] =>
[accessToken:protected] =>
[fileUploadSupport:protected] =>
[trustForwarded:protected] =>
)
Can I access theese values asynchronosly somehow?
That's because you're only logged as a Facebook application if you can access the signed_request token. This token is sent with the initial request (as a POST parameter), but isn't inside a cookie of anything.
The easiest thing with your actual code would be to re-send this signed request parameter with every ajax request you make so the server and Facebook SDK has access to that information.
But just to check if the user liked the current page. I'd suggest you print the data on the page directly so it is available from the start. Pseudo example:
<script>
window.data = {};
window.data.page_liked = <?= encode_json((boolean)$signed_request['page']['liked']) ?>;
</script>
To know if a user liked the page while he is on the splash page, you place a listener on a facebook event:
FB.Event.subscribe("edge.create", function( response ) {`
if ( response.match(/* RegExp matching your FB page url */) ) {
// user liked!
}
});
response is the URL liked, so you just have to compare it to your page url (facebook.com/MyPage) and then you know if a user clicked the like button in your application.
On a side note, generally the cleanest way to request user information is to login the user (OAuth), and pass requests directly from JS to the Open Graph (you use Angular anyway, so your app must be frontend based already). Your server shouldn't be used as a middle step between the Open Graph and your app, you'll duplicate code for without advantages.
This does not apply to the page.liked property, as it is a page property (not a user one) sent with the signed_request on app loading.