vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB5 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=263)
-   -   Any API call for updating a social group icon? (https://vborg.vbsupport.ru/showthread.php?t=323988)

incursio 12-07-2016 01:24 PM

Any API call for updating a social group icon?
 
I've been digging for a bit, but haven't found anything concrete yet.

Basically, I just need a way to set/update a social group icon image from a separate script. Any ideas? Thanks in advance for any guidance!

Cheers.

noypiscripter 12-07-2016 03:50 PM

Call the /uploader/uploadSGIcon frontend controller. To see what parameters are passed, try inspecting the AJAX call when you go to the group channel page and then clicking Edit Group Icon that appears when you hover the group icon, and then upload an image.

You can see the code for uploadSGIcon in actionUploadSGIcon() function in /includes/vb5/frontend/controller/uploader.php.

incursio 12-07-2016 04:44 PM

Yeah, I was looking at that. Not sure what you mean by "call the controller", though. That file isn't part of the API, right?

EDIT: Oh, you mean call it by CURL or what not ... yeah that would work :p

--------------- Added [DATE]1481137794[/DATE] at [TIME]1481137794[/TIME] ---------------

Actually, after tinkering a bit, that won't work, at least not as easily, because you run into vBulletin authentication issues with the cURL request :(

Replicant 12-07-2016 07:51 PM

You have to be logged in with the stay logged in check box clicked so that the cookies are set. Then when you call the function with curl, make sure the cookie info is included on the command line. If you are logged in and the cookie info is included, there are no authentication issues. I do it all the time.

incursio 12-07-2016 09:36 PM

I was building this as a command line tool as it might need to run via cron, but I suppose I can make it browser based instead.

Cheers.

noypiscripter 12-07-2016 11:38 PM

If you look into the actionUploadSGIcon() method in the controller, you would see that it is calling the upload method in the content_attach API to upload the image and then calling the update method in the content_channel API to update the social group channel with the uploaded image.

PHP Code:

$response $api->callApi('content_attach''upload', array('file' => $_FILES['file']));
...
$response $api->callApi('content_channel''update', array($_REQUEST['nodeid'], array('filedataid' => $response['filedataid']))); 

You can basically do the same.

incursio 12-07-2016 11:40 PM

Yeah, that's what I ended up doing! :p

Cheers.


All times are GMT. The time now is 06:52 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.00949 seconds
  • Memory Usage 1,723KB
  • 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_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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