vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB5 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=263)
-   -   How to get the thread URL from a nodeid? (https://vborg.vbsupport.ru/showthread.php?t=321752)

ndoktoruser 02-08-2016 03:48 PM

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?

Replicant 02-09-2016 12:34 AM

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}

ndoktoruser 02-09-2016 01:31 PM

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.

Replicant 02-10-2016 01:32 PM

1 Attachment(s)
Quote:

Originally Posted by ndoktoruser (Post 2564519)
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.

ndoktoruser 02-15-2016 03:34 PM

Amazing!

And much simpler now:
PHP Code:

$url vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($id); 


excentryk 10-07-2020 07:18 PM

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?


All times are GMT. The time now is 04:47 AM.

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.01476 seconds
  • Memory Usage 1,732KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete