Can't retrieve XMPP messages by MAM after a specified id - xmpp

I'm writing an xmpp messenger. By my design it stores local message history. When the user comes online and opens the dialog with someone my program requests archive (XEP-313) from the last locally stored message to the last message the server archive has, using "after" tag.
However it isn't working the way I expected it to.
The request
<iq id="qxmpp21" type="set">
<query xmlns="urn:xmpp:mam:1" queryid="qxmpp21">
<x xmlns="jabber:x:data" type="submit">
<field type="hidden" var="FORM_TYPE"><value>urn:xmpp:mam:1</value></field>
<field type="text-single" var="with"><value>user1#domain.org</value></field>
</x>
<set xmlns="http://jabber.org/protocol/rsm">
<max>100</max>
<after>5d10ba97-9ce8-46d4-9547-4f5e91e4ac19</after>
</set>
</query>
</iq>
The response
<iq xmlns="jabber:client" id="qxmpp21" xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace" type="result" from="user2#domain.org" to="user2#domain.org/QXmpp">
<fin xmlns="urn:xmpp:mam:1" queryid="qxmpp21" complete="true">
<set xmlns="http://jabber.org/protocol/rsm">
<count xmlns="http://jabber.org/protocol/rsm">465</count>
</set>
</fin>
</iq>
I use qxmpp library and ejabberd as a server.
Am I doing anything wrong?
Thanks in advance!

Related

Facebook Graph API: Update Page Post Message

I'm trying to use the facebook graph api to update the message on a previous post. I have the original post id and a valid never ending user access token. I am getting a "success" message back, but the post message is NOT getting updated.
<CFHTTP METHOD="POST" URL="https://graph.facebook.com/v3.2/#qPost.PostID#?message=#URLEncodedFormat(Message)#&access_token=#AccessToken#" THROWONERROR="YES">
<cfhttpparam type="header" name="Accept-Encoding" value="*" />
<cfhttpparam type="header" name="TE" value="deflate;q=0" />
</CFHTTP>
Success Message:
I'm going off the facebook graph details here (i know it says publish_actions permission has been removed), but certainly there has to be a way to update a page post via the graph api.
https://developers.facebook.com/docs/graph-api/reference/v3.2/post#updating
Also when I say I'm trying to update the message, basically the text that is written in the post (see image)
I got this figured out, i was not using the full postid in my request. When the original post was created it sends back a post id, which is a combination of the pageid and the postid (with an underscore in between), it looks like this below, with the first part being the pageid and the one after the underscore being the postid, I was only putting the 2nd part as the postid:
334797943936653_2003899366299670
It's funny that i would still get a "success" even though I had an invalid postid.
The documentation example states
POST /v3.2/post-id HTTP/1.1
Host: graph.facebook.com
message=This+is+a+test+message
So message is part of the POST body. But your code sends the message as part of the query string. Solution: Move message and access_token to the body.
<cfhttp method="POST" url="https://graph.facebook.com/v3.2/#qPost.PostID#" throwOnError="true">
<cfhttpparam type="header" name="Accept-Encoding" value="*" />
<cfhttpparam type="header" name="TE" value="deflate;q=0" />
<cfhttpparam type="formfield" name="message" value="#Message#" />
<cfhttpparam type="formfield" name="access_token" value="#AccessToken#" />
</cfhttp>
Encoding is done by cfhttpparam automatically, so keep the readable/desired text in the message variable.

Unable to upload image to a Coldfusion REST API Service

I am using CF10 REST API Service and trying to upload an a profile picture for a user.
The service method tries to save this image to a destination:
<cfcomponent rest="true"
restpath="/users">
<cffunction name="saveProfilePicture"
access="remote"
httpmethod="POST"
restpath="{userid}/profilePicture"
returntype="any">
<cfargument name="uploadedImage" required="true"/>
<cfargument name="userid" required="true" restargsource="Path"/>
<cffile
action="upload"
destination="#upload_path#"
fileField="uploadedImage"
result="profilePicture"
accept="image/jpg"
/>
</cffunction>
</cfcomponent>
I am trying to call this service as follows:
<form method="POST" enctype="multipart/form-data" action="#path#/users/#userid#/profilePicture">
<input type="file" name="uploadedImage"/>
<input type="submit" name="btn_submit_profilePicture" id="btn_submit_profilePicture"
value="Submit"/>
</form>
After I make this call I get an error message "Unsupported Media Type".
I get the same issue if I use cfhttp:
<cfhttp url="#path#/users/#userid#/profilePicture"
result="restResult" method="POST" multipart="true">
<cfhttpparam file="someimage.jpg" mimetype="image/jpg"
name="uploadedImage" type="file"/>
</cfhttp>
I have tried to search around but couldn't find a solution that works.
I can't use a framework as of now as most of the API is already implemented over CF REST API so guess I am stuck with it.
Any help would be greatly appreciated. Thanks.
Change your code like the following and test it.
<cfcomponent rest="true"
restpath="/users">
<cffunction name="saveProfilePicture"
access="remote"
httpmethod="POST"
restpath="{userid}/profilePicture"
returntype="any">
<cfargument name="uploadedImage" restargsource="form"/>
<cfargument name="userid" restargsource="Path"/>
<cffile
action="upload"
destination="#upload_path#"
result="arguments.uploadedImage"
accept="image/jpg,image/jpeg"
/>
</cffunction>
</cfcomponent>

Facebook page admin did not have publish actions permission

I want to do a facebook post from my coldfusion application to a test page. I have created a test page and I am the admin of that page. Now I got the API key and Page ID with the given details. The issue is when I post the request to facebook using
<cfhttp url="https://graph.facebook.com/v2.2/#MyPageID#/feed" result="access" >
<cfhttpparam type="formfield" name="access_token" value="#MyAccessToken#" />
<cfhttpparam type="formfield" name="message" value="#MyMessage#" />
</cfhttp>
I am getting all the posts from my page and the message is not posted. Can anyone help? Please let me know if you need any more help.
Oh. It is just a simple mistake and it made me to hang for hours. After wasting much hours, I have found that the HTTP call method must be post.
<cfhttp url="https://graph.facebook.com/v2.2/#MyPageID#/feed" result="access" method="false">
<cfhttpparam type="formfield" name="access_token" value="#MyAccessToken#" />
<cfhttpparam type="formfield" name="message" value="#MyMessage#" />
</cfhttp>
So the final lesson is, when the method is get, it reads the posts and when it is post, it adds a new post.

Adding properties to uploaded content in Alfresco

I am using Alfresco Web Quick Start to create a basic CMS website. I was wondering if someone could explain how to add properties/metadata to content which I have uploaded. For example if I have a gallery of images (with the default metadata of Author, Published, Size and Mime Type) and wanted to have a data taken property etc, how would I implement this?
I have done some research but am yet to find a concrete solution, any help on this matter would be greatly appreciated! Thanks!
The available metadata for a given node in Alfresco are dictated by its type and aspects.
Alfresco already ships with an EXIF aspect (look here for "exif:exif") you might want to use for your use case, which unfortunately the WCM QS hides. You should create a share-config-custom.xml file (sample here, official docs) which should list all the fields from the exif:exif aspect you want to expose.
Something like the following should work:
<config evaluator="model-type" condition="exif:exif">
<forms>
<form>
<field-visibility>
<show id="exif:dateTimeOriginal"/>
</field-visibility>
</form>
</forms>
</config>
It is a royal pain in the ass.
First you need to create a Model. Inside that model you need to create an Aspect. All this goes in XML file #1.
Then you need a context file to register the aspect. This is XML file #2.
And a properties files to give the aspect a friendly name.
And a web-site-custom-config to list all of the properties that were listed in XML file 1. This is XML file #3
And you need a share-custom-config. This has a different format from XML file #3, but serves the same purpose.
And finally you need to create a rule that automatically applies the aspect to each item in a folder.
Reference: http://blogs.alfresco.com/wp/wabson/2010/02/25/adding-custom-aspect-support-in-alfresco-share/
share-custom-config.xml
<alfresco-config>
<!-- Repository Library config section -->
<config evaluator="string-compare" condition="RepositoryLibrary" replace="true">
<!--
Whether the link to the Repository Library appears in the header component or not.
-->
<visible>true</visible>
</config>
<config evaluator="string-compare" condition="DocumentLibrary">
<!--
Used by the "Manage Aspects" action
For custom aspects, remember to also add the relevant i18n string(s)
cm_myaspect=My Aspect
-->
<aspects>
<!-- Aspects that a user can see -->
<visible>
<aspect name="my:sampleProps" />
<aspect name="ac:androidContentProps" />
</visible>
<!-- Aspects that a user can add. Same as "visible" if left empty -->
<addable>
</addable>
<!-- Aspects that a user can remove. Same as "visible" if left empty -->
<removeable>
</removeable>
</aspects>
</config>
<config evaluator="node-type" condition="cm:content">
<forms>
<form>
<field-visibility>
<!-- fields from my example aspect -->
<show id="my:propOne" />
<show id="my:propTwo" />
<show id="my:propInt" />
<show id="my:propFloat" />
<show id="my:propDateTime" />
<show id="my:propDate" />
<show id="my:propBoolean" />
<show id="my:propQName" />
<show id="my:propCategory" />
<show id="my:propNodeRef" />
<show id="my:propPath" />
<!-- fields for android content -->
<show id="ac:propNotify" />
<show id="ac:propNotificationSummary" />
<show id="ac:propArchiveDate" />
<show id="ac:propPublishDate" />
<show id="ac:propPriority" />
<show id="ac:propRegion" />
<show id="ac:propMarket" />
<show id="ac:propDistrict" />
<show id="ac:propStore" />
</field-visibility>
</form>
</forms>
</config>
<config evaluator="string-compare" condition="Remote">
<remote>
<endpoint>
<id>alfresco-noauth</id>
<name>Alfresco - unauthenticated access</name>
<description>Access to Alfresco Repository WebScripts that do not require authentication</description>
<connector-id>alfresco</connector-id>
<endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
<identity>none</identity>
</endpoint>
<endpoint>
<id>alfresco</id>
<name>Alfresco - user access</name>
<description>Access to Alfresco Repository WebScripts that require user authentication</description>
<connector-id>alfresco</connector-id>
<endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
<identity>user</identity>
</endpoint>
<endpoint>
<id>alfresco-feed</id>
<name>Alfresco Feed</name>
<description>Alfresco Feed - supports basic HTTP authentication via the EndPointProxyServlet</description>
<connector-id>http</connector-id>
<endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
<basic-auth>true</basic-auth>
<identity>user</identity>
</endpoint>
<endpoint>
<id>activiti-admin</id>
<name>Activiti Admin UI - user access</name>
<description>Access to Activiti Admin UI, that requires user authentication</description>
<connector-id>activiti-admin-connector</connector-id>
<endpoint-url>http://localhost:8080/alfresco/activiti-admin</endpoint-url>
<identity>user</identity>
</endpoint>
</remote>
</config>
</alfresco-config>

cfhttp multipart & facebook

I'm playing with the facebook graph api, and was attempting to send an image to my wall. According to facebook, you just send the image, your access key & a caption... see below my code:
<cfoutput>
<cfif fileexists("D:\myPath\images\menubar.jpg")>
<cfhttp method="post" url="https://graph.facebook.com/me/photos" multipart="yes">
<cfhttpparam type="formfield" name="access_token" value="myAccessToken">
<cfhttpparam type="file" name="source" file="D:\myPath\images\menubar.jpg">
<cfhttpparam type="formfield" name="message" value="this is a test picture.">
</cfhttp>
<cfdump var="#cfhttp#">
</cfif>
</cfoutput>
When I run this, I get a 400 bad request error ("OauthException an unknown error occurred" returns from facebook). Does anyone know what I'm doing wrong? Thanks!
can you check your access token format?
usually parameters set as access_token=somedata&expires=sometimestamp
At the statement you mentioned above, you have to pass just access token literally. I make it bold here. access_token=somedata&expires=sometimestamp
I've been trying to solve the same problem nearly for 3 hours. :) and finally did!
I've run into issues using https when the secure certificate hasn't been imported into the Java/ColdFusion keystore. More info on how to achieve that here:
http://kb2.adobe.com/cps/400/kb400977.html
Hope that helps!