Resource icon

XenForo SDK 0.0.1

No permission to download

Vincent Gabriel

Active member
Vincent.Gabriel submitted a new resource:

XenForo SDK - Software Development Kit

Simple SDK to allow using the XenForo Classes, Helpers, Templates etc.. outside of the XenForo Scope.

Features:
  • Check if user is logged in
  • Login
  • Logout
  • Validate Login Information
  • Verify Username
  • Verify Email
  • Encrypt/Validate Passwords
  • Create Users
  • Get current user/visitor information
  • Get forum/forums (using ids or conditions)
  • Get thread/threads (using ids or conditions)
  • Render Public/Admin Templates
  • Get all options
  • Get single option
...

Read more about this resource...
 
wow u read my mind bro i just wana come and write post for the login stuff on another script :p

but i just wondring

what i can do after login !!

like can i get the group id of that user ? so the script will work just for those who in group ( 9,10 for example ) .,

and thanks
 
Not sure what you are looking to do but to get the group id of the current user (or any user) you can do:

PHP:
$user = $sdk->getUser(); // or set an id getUser(12)
echo $user['user_group_id'];
 
Nice one:)

May i suggest to add following code to your constructor before you start the session:
PHP:
$dependencies = new XenForo_Dependencies_Public();
  $dependencies->preLoadData();

Without this code, the event system won't be initialized
 
Some improvement suggestions:
verifyUsername /verifyEmail => copying the the DW code isn't the best solution, what if an addon changed the method? your sdk won't implement this changes,....
it would be much better if you would use the DW to verify the data;)


getUser()=> instead of returning the empty array, you could return the array from xenforo_model_user::getVisitingGuestUser (just to have 100% the same data like in XF)

I had a similar helper class in the past, that's why i'm familiar with such problems:D

Is this available on github?:whistle:
 
Some improvement suggestions:
verifyUsername /verifyEmail => copying the the DW code isn't the best solution, what if an addon changed the method? your sdk won't implement this changes,....
it would be much better if you would use the DW to verify the data;)


getUser()=> instead of returning the empty array, you could return the array from xenforo_model_user::getVisitingGuestUser (just to have 100% the same data like in XF)

I had a similar helper class in the past, that's why i'm familiar with such problems:D

Is this available on github?:whistle:

Some of the verify methods were throwing errors when i was trying to do that, suggestions/contributions are welcome. this is a WIP and first release will take some time to get it to a stable more robust version.

https://github.com/VinceG/xenforo-sdk
 
I would like to render a single thread (by threadId) in a widget (widget framwork). It should work as a normal thread with all ist comments.
 
I'm probably completely overlooking something obvious here, so sorry for asking a potentially dumb question.

I can get data for a user by ID using
Code:
$user = $sdk->getUser(54857);
Is it possible for me to get data using their username, using something such as
Code:
$user = $sdk->getUser("JackBiggin");
(I tried this and it didn't work, but suspect I'm simply using the wrong syntax).
 
I'm probably completely overlooking something obvious here, so sorry for asking a potentially dumb question.

I can get data for a user by ID using
Code:
$user = $sdk->getUser(54857);
Is it possible for me to get data using their username, using something such as
Code:
$user = $sdk->getUser("JackBiggin");
(I tried this and it didn't work, but suspect I'm simply using the wrong syntax).
No, the code only works based on ID. You could modify it if you wanted.
 
Really nice resource thanks.

But does anyone know how you can use the getThreads method to display the threads you want in the order that you want?

On my website you'll see an Forum Box pulling latest threads, but its pulling the very first threads from 2007 as opposed to the very latest;

This is what I'm currently using;

Code:
                <div id="frm-content" class="widget">
                    <div class="title">From The Forum</div>
                    <ul class="forum">
                        <?php
                            $threads = $xenforo->getThreads(array(), array('limit' => 10));
                           
                            function date_sort($a, $b) {
                                return  $b['last_post_date'] - $a['last_post_date'];
                            }
                           
                            usort($threads, 'date_sort');
                           
                            foreach($threads as $thread) {
                                echo('<li><a href="' . $CONF['site'] . '/forum/threads/' . urls($thread['title']) . '.'. $thread['thread_id'] .'">' . $thread['title'] . '</a></li>');
                            }
                        ?>
                    </ul>
                </div>
 
Anyone got the login methods working on 1.3?
Specifically the login method (with or without validation) doesn't seems to be working for me. It returns the correct user id/true, but when I go to the forums I am not logged in :/
 
Last edited:
Back
Top Bottom