#1
|
|||
|
|||
![]()
I have a problem trying to call the function removeLinks through the API. I am currently using the MYJDAPI library (**External links are only visible to Support Staff****External links are only visible to Support Staff**) using PHP code.
In this library there is a function called callAction to make the call to the API. I use the following call: Code:
$this->callAction("/downloadsV2/removeLinks",$links); |
#2
|
||||
|
||||
![]()
can you please share full code that we can use for testing? for example what is $links in your case?
__________________
JD-Dev & Server-Admin |
#3
|
|||
|
|||
![]() Code:
$links="1526450046583";//UUID for delete $this->callAction("/downloadsV2/removeLinks",$links); function callAction( $action, $params = false) { if( !is_array( $this -> devices)) { $this -> enumerateDevices(); } if( !is_array( $this -> devices) || ( count( $this -> devices) == 0)) { return false; } foreach( $this -> devices as $i => &$ivalue) { if( $this -> devices[$i]["name"] == $this->getDeviceName()) { $device_id = $this -> devices[$i]["id"]; } } if( !isset( $device_id)) { return false; } $query = "/t_".urlencode( $this -> sessiontoken)."_".urlencode( $device_id).$action; if( $params != "") { if(is_array($params)) { $params = str_replace('"', '\"', substr(json_encode($params),1,-1)); } $json_data = '{"url":"'.$action.'","params":["{'.$params.'}"],"rid":'.$this -> getUniqueRid().',"apiVer":'.$this -> apiVer.'}'; } else { $json_data = '{"url":"'.$action.'","rid":'.$this -> getUniqueRid().',"apiVer":'.$this -> apiVer.'}'; } $json_data = $this -> encrypt( $json_data, $this -> deviceEncryptionToken); $url = $this -> api_url.$query; $res = $this -> postQuery( $url, $json_data, $this -> deviceEncryptionToken); if( $res === false) { return false; } $content_json = json_decode( $res, true); if( $content_json["rid"] != $this -> rid_counter) { return false; } return $content_json; } function postQuery( $url, $postfields = false, $iv_key = false) { $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $url); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true); if( $postfields) { $headers[] = "Content-Type: application/aesjson-jd; charset=utf-8"; curl_setopt( $ch, CURLOPT_POST, true); curl_setopt( $ch, CURLOPT_POSTFIELDS, $postfields); curl_setopt( $ch, CURLOPT_HEADER, true); curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers); } $response = array(); $response["text"] = curl_exec( $ch); $response["info"] = curl_getinfo( $ch); $response["code"] = $response["info"]["http_code"]; if( $response["code"] != 200) { return false; } if( $postfields) { $response["body"] = substr( $response["text"], $response["info"]["header_size"]); } else { $response["body"] = $response["text"]; } if( $iv_key) { $response["body"] = $this -> decrypt( $response["body"], $iv_key); } curl_close( $ch); return $response["body"]; } Last edited by contertulio; 16.05.2018 at 09:01. |
#4
|
||||
|
||||
![]()
https://my.jdownloader.org/developers/#tag_147
check /downloadsV2/removeLinks it expects two long arrays and not a single String 1 - linkIds (long[]) 2 - packageIds (long[]) Call /downloadsV2/removeLinks?linkIds&packageIds As far as I remember this client does not support parametes correct as it always merges the param into a single object This part is wrong! "params":["{'.$params.'}"] < it will put all params within a single object {} This must be changed/fixed to use the original param object, for example like callAction("/downloadsV2/removeLinks",[[1526450046583],[]]); params is an array of objects, in this case an array of two long arrays and then modify the callAction method to convert this object into json string
__________________
JD-Dev & Server-Admin |
#5
|
|||
|
|||
![]()
Perfect, that works like a charm!! Thank you
|
#6
|
||||
|
||||
![]()
did you modify the callAction method or what did you do to make it work? would be nice if you can share your fix/change for others
__________________
JD-Dev & Server-Admin |
#7
|
|||
|
|||
![]()
I modify:
PHP Code:
$json_data = '{"url":"'.$action.'","params":["{'.$params.'}"],"rid":'.$this -> getUniqueRid().',"apiVer":'.$this -> apiVer.'}'; |
#8
|
||||
|
||||
![]()
Thanks for the feedback! Whenever you have questions about api or need help, please don't hesitate and contact us again
__________________
JD-Dev & Server-Admin |
![]() |
Thread Tools | |
Display Modes | |
|
|