استفاده از API

 

 

- متدها (EndPoints) :

[GET] /api/getImageHome/:order
[GET] /api/getImageWall/:order
Field Type Description
order String date, comment, view, download, like

- کد نمونه برای دانلود و قرار دادن عکس برای تصویر زمینه در لینوکس

#!/bin/bash

# $saveDir is used to set the location where Bing pics of the day
# are stored.  $HOME holds the path of the current user's home directory
saveDir=$HOME'/Pictures/vollip/'

# Create saveDir if it does not already exist
mkdir -p $saveDir

cd $saveDir

# Set picture options
# Valid options are: none,wallpaper,centered,scaled,stretched,zoom,spanned
picOpts="zoom"

# request to server and get the image url ** you can change this with other end points **
fileLink=$(curl -s https://sajadabasi.ir/vollip/api/getImageHome)

# split the url by '/''
arrIN=(${fileLink//// })
# select last part of splited url and it's file name
picName="${arrIN[6]}"

# check if file exists won't redownload it
if [ ! -f "$saveDir$picName" ]
then
    # Download the image and save it
    curl -s -o $saveDir$picName $fileLink
    #if you want picture of day do this
    curl -s -o $saveDir$picName 'https://vollip.ir/page/imageWithCaption/?img='$fileLink
fi

# Set the GNOME3 wallpaper
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-uri '"file://'$saveDir$picName'"'

# Set the GNOME 3 wallpaper picture options
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-options $picOpts

# Exit the script
exit

- برای تغییر اتوماتیک تصویر پس زمینه cronjob زیر را در لیست cronjobs خود قرار دهید:

* */4 * * * /path/to/code.sh