Posting/retrieving photo-comments using Graph API - facebook

When I use the Graph API to fetch a comment containing an image, the returned JSON contains no reference to it, e.g.
{
  "id": "10151452996201039_9302037",
  "from": {
    "name": "Anton Raxacoricofallapatorius Dyudin",
    "id": "1534947411"
  },
  "message": "",
  "can_remove": true,
  "created_time": "2013-06-20T06:47:41+0000",
  "like_count": 0,
  "user_likes": false
}
I am likewise lost as to what POST field can be used to embed a picture when commenting.
How can I achieve either of the above?

Add fields=attachment to your query.
https://developers.facebook.com/docs/graph-api/reference/comment

It actually works when you use fields=attachment
https://graph.facebook.com/POSTID_COMMENTID?fields=attachment&access_token=ACCESS_TOKEN

If you want a more extensive query that return everythings and I mean everything including user id's, profile image (large version), comment related info as well and attachement info use this.
&fields=id,status_type,created_time,from{name,id,picture.width(400).height(400)},message,picture.width(400).height(400),link,icon,comments{comments{attachment,from{picture.width(400).height(400),name},id,message,created_time},from{picture.width(400).height(400),name},id,message,attachment,created_time}

Related

How to retrieve youtube comments from a specific video using Eclipse

I have set up everything according from the guide here : https://developers.google.com/gdata/articles/eclipse
From there on, how do I start to retrieve the comments?
I'm sort of a beginner so it would be great if anyone could provide some codes to start off.
Firstly, you should download libraries and install required libraries shown in the page your link has.
To get comments from a youtube video you should send this URL : http://gdata.youtube.com/feeds/api/videos/VIDEO_ID/comments
YouTubeService service = new YouTubeService(
YOUR_CLIENT_ID);
String url="http://gdata.youtube.com/feeds/api/videos/VIDEO_ID/comments";
VideoEntry videoEntry = service.getEntry(new URL(url),
VideoEntry.class);
String commentUrl = videoEntry.getComments().getFeedLink().getHref();
CommentFeed commentFeed = service.getFeed(new URL(commentUrl),
CommentFeed.class);
for (CommentEntry comment : commentFeed.getEntries()) {
System.out.println(comment.getPlainTextContent());
}
You can get last 25 comments via this code. If you want to get more than 25 comments, you should read about pagination, max-results, start-index parameters.

CQ5.5: getting Style of a target page

I've been working on this for sometime now, and I keep running into a wall. I think I'm close, but I figured someone out here in the land of SO might have some deeper insight if not a better way of doing what I'm trying to do.
Basically lets look at this scenario. I have a logo w/ some text that can be set from a few different places. If we look at the setup here is what it looks like.
Hiearchy:
Homepage [has designPath]
- Child Microsite Page [has designPath]
- Logo Component
Logic Flow (in logo component):
if properties.get("logoText") {
use this
} else if currentStyle.get("logoTextFromStyle") {
use this
} else if parentStyle.get("logoTextFromGlobal") {
use this
} else {
be blank
}
My query is with how to get the "parentStyle" of this page. Looking at the docs here: http://dev.day.com/docs/en/cq/5-5/javadoc/com/day/cq/wcm/api/designer/Style.html
I've been able to come up with the fact that I can get a Style object from the "designer" object made available via defineObjects. This is defined with the other utility objects like "pageManager, resourceUtil, resource, currentPage, etc".
With that being said this doesn't seem to work.
//assuming we have getting homePage earlier and it is a valid cq Page resource
Resource homePageResource.slingRequest.getResourceResolver().getResource(homePage.getPath());
Style homePageStyle = designer.getStyle(homePageResource);
at this point homePageStyle is null. To do some more testing I i tried passing currentPage.getPath() instead of homePage.getPath(). I assumed this would give me the currentPage resource and would in end yield the currentStyle object. This also resulted in a null Style object. From this I think I can safely conclude I'm passing the incorrect resource type.
I attempted to load the the cq:designPath into the resource hoping to get a Designer resourceType but to no avail.
I am curious if anyone has run into this problem before. I apologize if I've gone into too much detail, but I wanted to lay out the "why" to my question as well, just in case there was a better way overall of accomplishing this.
I've figured out how to return the style. Here is the rundown of what I did.
//get your page object
Page targetPage = pageManager.getPage("/path/to/target");
//get the Design object of the target page
Design homePageDesign = designer.getDesign(homePage);
//extract the style from the design using the design path
Style homePageStyle = homePageDesign.getStyle(homePageDesign.getPath());
it's very interesting the definition of "getStyle" is a little different from the designer.getStyle vs a Design.getStyle. designer.getStyle asks for a resource whereas Design.getStyle will take the path to a Design "cell" and return the appropriate Style.
I did some testing and it looks like it does work with inherited Styles/Designs. So if my cq:designPath is set at level 1 and I look up a page on at level 2 they will return the Design/Style at the cq:designPath set at level 1.
I hope this helps someone else down the way.
I tried this approach but was not getting the Styles in the Style object.
When we do this:
Design homePageDesign = designer.getDesign(homePage);
In this Design object we get the path till the project node i.e etc/design/myproject
After this if we try to extract the Style from the design path we do not get it.
However I implemented it in a different way.
In the design object, we also get the complete JSON of designs for(etc/design/myproject).
Get the sling:resourceType of the target page and get the value after last index of "/".
Check if this JSON contains the last value. If it contains, you can get your styles, i.e. image, etc.

user_work_history with Flex and the ActionScript SDK

I'm working on a sample app for Facebook, using Flash Builder and Flex.
Now, I've got everything up and running - but there's one problem, specifically with the work history part.
When I try to display the user's work history..here's the code for logging in:
protected function login():void
{
FacebookDesktop.login(loginHandler, ["user_birthday", "user_work_history"]);
}
Here, loginHandler's a callback function, that then goes ahead and displays data about the user:
protected function loginHandler(success:Object,fail:Object):void
{
if (success){
currentState = "LoggedIn";
fname.text = success.user.name;
userImg.source=FacebookDesktop.getImageUrl(success.uid,"small");
birthdayLbl.text=success.user.birthday;
workLbl.text=success.user.work;
}
}
Now, the problem occurs with success.user.work - it ends up printing the following:
[object,Object],[object,Object],[object,Object],[object,Object]
Obviously, I'm doing something wrong..but I can't figure out what exactly it is. Would be grateful for some pointers!
Thanks!
Rudi.
The object contained in success.user.work is most likely an array of objects, each item representing a work period, so you'll have to treat it as such. Either use a list and a custom renderer for each item, or create a string by iterating over the array, and appending the fields that you're interested in.
To see what the individual objects contain, either use a breakpoint during debug and inspect them, or check to see if they're documented in the facebook development documentation.

Is it possible to only post fxml comments without letting a user enter a comment by themself?

Im want to let the user to see the comments done to a topic without giving him the opportunity to enter a comment by his one! Is this possible with fxml? canpost="false" doesn't work for any reason...
Is this possible at all?
Thanks
Markus
Well lets take a look at sources. If we open http://connect.facebook.net/en_US/all.js it has the following piece of code:
FB.subclass('XFBML.Comments', 'XFBML.IframeWidget', null, {
_visibleAfter: 'resize',
_refreshOnAuthChange: true,
setupAndValidate: function () {
var a = {
channel_url: this.getChannelUrl(),
css: this.getAttribute('css'),
notify: this.getAttribute('notify'),
numposts: this.getAttribute('num-posts', 10),
quiet: this.getAttribute('quiet'),
reverse: this.getAttribute('reverse'),
simple: this.getAttribute('simple'),
title: this.getAttribute('title', document.title),
url: this.getAttribute('url', document.URL),
width: this._getPxAttribute('width', 550),
xid: this.getAttribute('xid')
};
...
It is a list of parameters that are getting passed to actual widget iframe.
Bad news is that there is no such parameter as canpost anymore even though it is still listed in their docs (anyone surprised?), so it just getting ignored.
Good news is that css parameter could be still supported. In good old days they allowed you to pass custom css (in a form of absolute url, http://mysite.com/style.css), but I doubt it still works. Try to create your custom css style with comment box hidden (check comments iframe for required class name) and pass it. If that doesn't work then there is nothing else you can do I'm afraid.

How to access hyperlinks in PDF documents (iPhone)?

Is it possible to get access to "internal" links in PDF documents using CGPDFDocument, or other means? I'm building a simple reader app and would like to deliver my content in PDF form, but if I can't support links between pages in the doc this probably isn't going to work.
This question is similar, but does not address the issue of how to support hyperlinks.
See my answer here. Basically, you'll need to get familiar with PDF link annotations.
see this sample code...pdf hyperlinks works in this
https://github.com/vfr/Reader
If you're using Quartz to open and view a PDF, then yes, it looks like you will have access to internal links. Quartz will also let you add new links to PDFs. I don't have any first hand experience with iPhone/Mac development, but it would be quite strange for them to let you add hyperlinks, but not use them.
You need to do in two steps.
First: Parse your pdf to locate marked content operators
That's an exemple of a parsing code :
-(void)parseContent() {
CGPDFOperatorTableRef myTable;
myTable = CGPDFOperatorTableCreate();
CGPDFOperatorTableSetCallback(myTable, "BMC", &myOperator_BMC);
CGPDFContentStreamRef myContentStream = CGPDFContentStreamCreateWithPage(page);
CGPDFScannerRef myScanner = CGPDFScannerCreate(myContentStream, myTable, autoZoomAreas);
CGPDFScannerScan(myScanner);
CGPDFScannerRelease(myScanner);
CGPDFContentStreamRelease(myContentStream);
}
void myOperator_BMC(CGPDFScannerRef s, void *info)
{
const char *name;
CGPDFScannerPopName(s, &name);
}
(You need to complete and adjust this code to match your requirement)
Second: respond to the toucheEnded message to handle tap on those zones and make the UI respond accordingly.