Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
  #1  
Old 02-08-2016, 03:48 PM
ndoktoruser ndoktoruser is offline
 
Join Date: Aug 2015
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to get the thread URL from a nodeid?

Let's suppose I have a node id (the integer value) which corresponds to a thread. How do I get the URL?
Reply With Quote
  #2  
Old 02-09-2016, 12:34 AM
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Location: Phoenix, Az. USA
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can get to the threads by nodeid using the www.example.com/forum/node/1234 where 1234 is the nodeid. Is that what you are looking for or are you looking for API?

from the command line ---- curl http://www.vbulletin.com/forum/ajax/...l?nodeid=54756
or javascript ---
Code:
$.ajax({
                url: 'http://www.vbulletin.com/forum/ajax/api/route/getAbsoluteNodeUrl',
                type: "POST",
                dataType: 'json',
                data: {
                nodeid:'547'
                },
                success: function(response) {
                        if (response){
                                alert(response);
                        }
                }
});
The ajax method is hit or miss. On VB 5.2, I don't know why, but if a user is logged in, this js throws an error, but for guests, works as expected.

You can also call the API in the templates using {vb:data}
Reply With Quote
Благодарность от:
Lynne
  #3  
Old 02-09-2016, 01:31 PM
ndoktoruser ndoktoruser is offline
 
Join Date: Aug 2015
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Once and again, thank you very much!

I did as you said using curl:

PHP Code:
$curl curl_init('http://my.page/ajax/api/route/getAbsoluteNodeUrl');
curl_setopt($curlCURLOPT_POSTFIELDS'nodeid=' $id);
curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
$url curl_exec($curl);
curl_close($curl); 
It was exactly what I needed.
Reply With Quote
Благодарность от:
MarkFL
  #4  
Old 02-10-2016, 01:32 PM
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Location: Phoenix, Az. USA
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ndoktoruser View Post
Once and again, thank you very much!

I did as you said using curl:

PHP Code:
$curl curl_init('http://my.page/ajax/api/route/getAbsoluteNodeUrl');
curl_setopt($curlCURLOPT_POSTFIELDS'nodeid=' $id);
curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
$url curl_exec($curl);
curl_close($curl); 
It was exactly what I needed.
If you are using this in a php script, you can call the api directly in the code also. It'll save an http request and be much faster if you are dealing with several urls. I included a screenshot of the docs for this function.
Attached Images
File Type: png route.png (45.9 KB, 0 views)
Reply With Quote
Благодарность от:
MarkFL
  #5  
Old 02-15-2016, 03:34 PM
ndoktoruser ndoktoruser is offline
 
Join Date: Aug 2015
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Amazing!

And much simpler now:
PHP Code:
$url vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($id); 
Reply With Quote
4 благодарности(ей) от:
bridge2heyday, Lynne, MarkFL, Replicant
  #6  
Old 10-07-2020, 07:18 PM
excentryk excentryk is offline
 
Join Date: Apr 2011
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello, sorry for response in old topic - but I have the same problem and don't know how to convert mysite.pl/forum/node1234 to full url to the post. I don't know how to use this getAbsoluteNodeUrl API. Any Tips?

Should create php file example converter.php and put this code in to this file?

I need only working redirection from mysite.pl/forum/node1234 to full url to the post how to do that?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:12 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03798 seconds
  • Memory Usage 2,247KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (7)post_thanks_box_bit
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (1)postbit_attachment
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete