• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XenForo SDK 0.0.1

No permission to download
#1
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...
 

TBDragon

Active member
#2
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
 
#3
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'];
 

xf_phantom

Well-known member
#5
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
 

xf_phantom

Well-known member
#7
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:
 
#8
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
 
#14
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.
 
#15
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).
 

James

Well-known member
#16
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.
 
#17
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>
 
#18
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: