New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API: XML is now generated without templates #2682
Conversation
"friendica" => "http://friendi.ca/schema/api/1/", | ||
"georss" => "http://www.georss.org/georss"); | ||
|
||
/// @todo Auto detection of needed namespaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not needed. Just always put in namespace declarations and make the parser happy.. The parser don't complain on unused declared ns, but will stop on used undeclared ones...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are XML that never will return something with different namespaces (like the IDs of friends). I find it a little bit ugly to return namespaces there. Of course this is only some beautification.
Do you think this is a show stopper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this is a show stopper?
absolutely not
Have you tried this with some clients? |
I don't know clients that use the XML, but I compared every API call with an older Friendica server version and with a GNU Social server. |
Ok, just give me some time to test it with Friendly :-) |
I will be so friendly :-) |
BTW: There had been massive differences between XML and JSON (missing fields and/or fields that aren't part of the JSON) and there were many functions that never had worked with XML output because of missing templates. |
Short note from my side (like always): Please add the description of the new db row to the db docu |
There is no new database row, just a new index. |
ahh ok. sorry |
@fabrixxm could you give me a hint how to install a sailfish emulator and this app? Then I could do some testing (for future changes) on my own. I want to do some more changes to the api in the future. |
you can find the SailfishOS SDK stuff here and the Friendly source is at Fabios projects repository. It's a customized QtCreator. You need the i486 kit an run it then in debug mode,. Open the |
@fabrixxm Have you done your testings? |
No, sorry, I'm quite busy right now. I'll test it this sunday. |
I was trying this PR but I have some problems because I'm on latest PHP (7.0.9) which raises a strange error:
Which is: $r = call_user_func($info['func'], $a, $type); Looks like it want I get this warning also in current develop, looks like a php regression. I never get any warning so far here. The only way I found to make it work is using $r = call_user_func_array($info['func'], array(&$a, $type)); That's made the code work in develop. If I change that line in this patch, I get a new series of warning:
|
So we just should drop passing the "a" variable to the functions. I could include this in the current pull request if you like. |
Update: I tried this I would simply change that line to use $r = call_user_func_array($info['func'], array(&$a, $type)); After this, there is the new warning in |
Ok, the warning is raised when there is an activity of an item. The array is:
So, every activity is an array of [user=>", url=>""] for every user that like or disliked or whatever the item. The code at As this is a friendica-only extension to the api output, we can decide how the xml should be, but I'm not sure on how to make the code work. Using templates I was thinking something like: <friendica:activities>
<like>
<contact>
<user>Mario Rossi</user>
<url>http://friendica.local/profile/mrossi</url>
</contact>
</like>
...
</activities> (Note that the in the current develop branch, the XML still returns only the count of every sinlge activity, while the json is updated) |
The warning because of $a should now have disappeared. Concerning the activities we should do it like Twitter once did (when they hadn't deprecated the XML output like they did now): there you have the plural and singular versions of the elements. Means: "statuses" and "status" or "users" and "user". We could do the same with "our" fields. |
|
||
if (is_integer($key)) { | ||
if (isset($element)) | ||
$element[0] = $value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for this I get the error PHP Warning: It is not yet possible to assign complex types to properties in /.../include/xml.php on line 55
with PHP 7.0.9.
Posting new entries works (but raises the error) fetching the home time line does not (using Friendly).
There is now a generic functionality to generate XML output for API calls. Additionally some old code was dropped (support for a deprecated Activity Streams output). Also there are some changes to the sql queries.
There is some work left at the queries. But I wanted to do the pull request now so that the changes are split in several pull requests.