2017-10-11 34 views
2

對於任何使用Freelancer.com Api的人。 我試圖通過API從這個平臺獲取所有活動項目並按最近發佈日期對它們進行排序,默認情況下按分數排序。 關於什麼sort_field值必須按最近的發佈日期進行排序沒有任何說法。項目排序Freelancer.com Api

$sorting_date = "????"; 
$requestUrl = "https://www.freelancer.com/api/projects/0.1/projects/active/?sort_field=" . $sorting_field; 
$response = json_decode(file_get_contents($requestUrl), 1); 

這裏是鏈接到API文檔: Freelancer.com API

也許沒有人有同樣的問題,需要幫助。

+1

你有沒有嘗試過這樣的:https://www.freelancer.com/api/projects/0.1/projects/active/?sort_field=submitdate –

+0

是的,我試過了,但結果相同。 –

回答

2

答案簡而言之: 您可以使用https://www.freelancer.com/api/projects/0.1/projects/active/不使用sort_field,因爲它是在最近的文章中默認情況下也會分類

說明 我測試的API,我發現,這是也排序最近發佈日期提交日期

根據自由職業者的文檔:

排序字段,默認情況下按分數搜索,否則最近發佈

我嘗試將結果限制爲3,並使用reverse_sort將結果限制爲測試它是否實際工作。 https://www.freelancer.com/api/projects/0.1/projects/active/?limit=3&reverse_sort=true

$requestUrl = "https://www.freelancer.com/api/projects/0.1/projects/active/?limit=3&reverse_sort=true"; 
$response = json_decode(file_get_contents($requestUrl), 1); 
echo "<pre>"; 
var_dump($response); 

這裏是result

搜索["submitdate"]CRTL + F並獲得值。

here轉換相當於日期

粘貼在這裏值reverse_sort轉換日期

Wed Sep 03 2014 21:14:19 GMT+0800 
Tue Jul 14 2015 23:11:36 GMT+0800 
Fri Jul 24 2015 05:46:41 GMT+0800 

結果如果我們刪除reverse_sort =真這裏是結果

Fri Dec 29 2017 12:45:13 GMT+0800 
Fri Dec 29 2017 12:44:49 GMT+0800 
Fri Dec 29 2017 12:44:29 GMT+0800 

正如你可以看到它是排序最近發佈日期

+1

非常感謝您的回覆! –

0

你可以嘗試這樣的事情嗎?這將返回與其ID相關的項目。

https://www.freelancer.com/api/projects/0.1/projects/active?jobs[]=106&sort_field=id