مقدمة

هذا الفهرس عبارة عن أمثلة لجميع الاستدعاءات المتاحة خارجيًا وداخليًا ، وأيضًا عرض للدوال المدعومة والمتاحة الجاهزة في نظام ديموفنف والتي تتيح للمطورين استخدام هذه الدوال للحصول على البيانات المختلفة حسب الحاجة.


يجب في كل الأحوال أن يكون للمستخدم الذي سيتصل بالــ API صلاحية :

- يمكنه الاتصال بالـ API وذلك من خلال صلاحيات مجموعة عضويته
- بعض الدوال المطلوبة في الاستدعاء قد تتطلب -أيضًا- وجود صلاحية معينة لتنفيذها ، وذلك حسب الموديول المطلوب أو حسب صلاحيات ديموفنف نفسها

الاستدعاء الخارجي

استدعاء الــ API للحصول على بيانات بشكل JSON

مثال
						
/* JSON API Sample Code */

# URL to DIMOFINF CMS site API file
$url = "http://www.yourdomain.com/api.php";

$postfields = array();
$postfields["username"] = "admin"; #username goes here
$postfields["password"] = "123"; #password goes here
$postfields["action"] = "getModules"; #action performed by the API:Functions
$postfields["datatype"] = "json";
#$postfields["pretty"] = true; # optional for pretty json print
#$postfields["module"] = "news"; # optional if requsting a specific module api
#$postfields["parameter1"] = 1; # optional
#$postfields["parameter2"] = "value"; # optional

// use curl to connect
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_POST, 1); # only post method allowed
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$data = curl_exec($ch);

if (curl_error($ch))
    {
        die("Connection Error: " . curl_errno($ch) . ' - ' . curl_error($ch));
    }
curl_close($ch);

$results = json_decode($data, true); # Decode JSON String

#print_r($results);	# Output json Response as Array

if ($results["result"] == "success")
    {
    /* Result was OK!
    YOUR ACTION HERE
    */
    }
else
    {
        # An error occured
        echo "The following error occured: " . $results["data"];
    }

# Debug Output - Uncomment if needed to troubleshoot problems
/* echo "";
*/

						
					

استدعاء الــ API للحصول على بيانات بشكل ARRAY

مثال
						
							/* ARRAY API Sample Code */

# URL to DIMOFINF CMS site API file
$url = "http://www.yourdomain.com/api.php";

$postfields = array();
$postfields["username"] = "admin"; #username goes here
$postfields["password"] = "123"; #password goes here
$postfields["action"] = "getModules"; #action performed by the API:Functions
$postfields["datatype"] = "array";
#$postfields["module"] = "news"; # optional if requsting a specific module api
#$postfields["parameter1"] = 1; # optional
#$postfields["parameter2"] = "value"; # optional

# use curl to connect
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_POST, 1); # only post method allowed
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$data = curl_exec($ch);

if (curl_error($ch))
    {
        die("Connection Error: " . curl_errno($ch) . ' - ' . curl_error($ch));
    }
curl_close($ch);

eval('$results=' . $data . ';'); // Decode ARRAY String

# print_r($results); # Output ARRAY Response as Array

if ($results['result'] == "success")
    {
    /* Result was OK!
    YOUR ACTION HERE
    */
    }
else
    {
        # An error occured
        echo "The following error occured: " . $results['data'];
    }

# Debug Output - Uncomment if needed to troubleshoot problems
/*echo "";
*/
						
					

استدعاء الــ API للحصول على بيانات بشكل SERIALIZE

مثال
						
							/* SERIALIZE API Sample Code */

# URL to DIMOFINF CMS site API file
$url = "http://www.yourdomain.com/api.php";

$postfields = array();
$postfields["username"] = "admin"; #username goes here
$postfields["password"] = "123"; #password goes here
$postfields["action"] = "getModules"; #action performed by the API:Functions
$postfields["datatype"] = "serialize";
#$postfields["module"] = "news"; // optional if requsting a specific module api
#$postfields["parameter1"] = 1; # optional
#$postfields["parameter2"] = "value"; # optional

# use curl to connect
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_POST, 1); # only post method allowed
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_REFERER, "http://" . $_SERVER['SERVER_NAME']);
$data = curl_exec($ch);

if (curl_error($ch))
    {
        die("Connection Error: " . curl_errno($ch) . ' - ' . curl_error($ch));
    }
curl_close($ch);

$results = unserialize($data); // Decode serialized String

# print_r($results); // Output serialized Response as Array

if ($results["result"] == "success")
    {
    /* Result was OK!
    YOUR ACTION HERE
    */
    }
else
    {
        # An error occured
        echo "The following error occured: " . $results["data"];
    }

# Debug Output - Uncomment if needed to troubleshoot problems
/*echo "";
*/
						
					

استدعاء الــ API للحصول على بيانات بشكل XML

يقوم هذا المبدل بفلترة النص بناءً على القيم المرسلة إليه , حيث يمكنه -على سبيل المثال- فلترة أكواد الـ html والجافا سكربت ، وكذلك علامات التنصيص

مثال
						
							/* XML API Sample Code */

# URL to DIMOFINF CMS site API file
$url = "http://www.yourdomain.com/api.php";

$postfields = array();
$postfields["username"] = "admin"; #username goes here
$postfields["password"] = "123"; #password goes here
$postfields["action"] = "getModules"; #action performed by the API:Functions
$postfields["datatype"] = "xml";
#$postfields["module"] = "news"; // optional if requsting a specific module api
#$postfields["parameter1"] = 1; # optional
#$postfields["parameter2"] = "value"; # optional

# use curl to connect
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_POST, 1); # only post method allowed
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_REFERER, "http://" . $_SERVER['SERVER_NAME']);
$data = curl_exec($ch);

if (curl_error($ch))
    {
        die("Connection Error: " . curl_errno($ch) . ' - ' . curl_error($ch));
    }
curl_close($ch);

function xmltoArray($arrObjData, $arrSkipIndices = array())
    {
        $arrData = array();

        if (is_object($arrObjData))
            {
                $arrObjData = get_object_vars($arrObjData);
            }

        if (is_array($arrObjData))
            {
                foreach($arrObjData as $index => $value)
                    {
                        if (is_object($value) || is_array($value))
                            {
                                $value = xmltoArray($value, $arrSkipIndices); // recursive call
                            }

                        if (in_array($index, $arrSkipIndices))
                            {
                                continue;
                            }
                        $arrData[$index] = $value;
                    }
            }
        return $arrData;
    }

$results = xmltoArray(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOBLANKS)); # Decode XML String

# print_r($results);	// Output XML Response as Array

if ($results["result"] == "success")
    {
    /* Result was OK!
    YOUR ACTION HERE
    */
    }
else
    {
        # An error occured
        echo "The following error occured: " . $results["data"];
    }

# Debug Output - Uncomment if needed to troubleshoot problems
/* echo "";
*/
						
					


الاستدعاء الداخلي


استدعاء الــ API الداخلي للحصول على بيانات بشكل JSON

مثال
						
/* JSON local API Sample Code */

$action = "getModules";
$values = array();
$values["datatype"] = "json";
#$values["module"] = "news"; # optional if requsting a specific module api
#$values["parameter1"] = 1; # optional
#$values["parameter2"] = "value"; # optional

$data = localAPI($action, $values);

$results = json_decode($data, true); # Decode JSON String

#print_r($results);	# Output json Response as Array

if ($results["result"] == "success")
    {
    /* Result was OK!
    YOUR ACTION HERE
    */
    }
else
    {
        # An error occured
        echo "The following error occured: " . $results["data"];
    }

# Debug Output - Uncomment if needed to troubleshoot problems
/* echo "";
*/
						
					

الدوال الجاهزة

addUser

يمكنك من إضافة مستخدم جديد

يجب أن يكون للمستخدم صلاحية التحكم بالأعضاء

البارميترز المطلوبة

الوصف البارام
اسم المستخدم ausername
اسم العرض للمستخدم displayname
الكلمة السرية apassword
البريد الإلكتروني email
بيانات الهوية (اختياري) - json encoded of userprofile array userprofile
رقم مجموعة العضوية (اختياري , الافتراضي 4) ausergroupid
مسمى العضو (اختياري) usertitle
جنس المستخدم (اختياري 0 رجل , 1 امرأة) gender

مثال الاستدعاء الخارجي

						
						$postfields["action"] = "addUser";
						$postfields["datatype"] = "json";
$postfields["ausername"] = 'hadeel';
$postfields["displayname"] = 'Hadeel Barakat';
$postfields["apassword"] = '123';
$postfields["email"] = '[email protected]';
$postfields["ausergroupid"] = 4;
$postfields["userprofile"] = json_encode(array(
	'country' => 'SA',
	'city' => 'Riyadh',
	'phone' => '12345',
	'verified' => 1
));
$postfields["gender"] = 1;
						
					

مثال الاستدعاء الداخلي

						
$action = "addUser";
$values = array();
$values["datatype"] = "json";
$values["ausername"] = 'hadeel';
$values["displayname"] = 'Hadeel Barakat';
$values["apassword"] = '123';
$values["email"] = '[email protected]';
$values["ausergroupid"] = 4;
$values["userprofile"] = json_encode(array(
	'country' => 'SA',
	'city' => 'Riyadh',
	'phone' => '12345',
	'verified' => 1
));
$values["gender"] = 1;

$data = localAPI($action, $values);
						
					

القيمة الناتجة في حالة النجاح

الوصف القيمة
نتيجة الاستدعاء - result success
رقم العضوية الجديدة التي تم إضافتها للجدول - data 765

القيمة الناتجة في حالة الفشل

الوصف القيمة
نتيجة الاستدعاء - result error
رسالة الخطأ المعادة من الاستدعاء - data The email address you entered is already in use



getOptions

يمكنك من جلب إعدادات ديموفنف

البارميترز المطلوبة

الوصف البارام
الإعداد (اختياري لجلب إعداد محدد فقط) option

مثال الاستدعاء الخارجي

						
						$postfields["action"] = "getOptions";
						$postfields["datatype"] = "json";
$postfields["option"] = 'copyrighttext';
						
					

مثال الاستدعاء الداخلي

						
$action = "getOptions";
$values = array();
$values["datatype"] = "json";
$values["option"] = 'copyrighttext';

$data = localAPI($action, $values);
						
					

القيمة الناتجة في حالة النجاح

الوصف القيمة
نتيجة الاستدعاء - result success
قيمة الإعداد - data جميع الحقوق محفوظة لموقع
قيمة الإعداد في حالة عدم تحديد الإعداد- data array('option1' => value1, 'option2' => value2)

القيمة الناتجة في حالة الفشل

الوصف القيمة
نتيجة الاستدعاء - result error
رسالة الخطأ المعادة من الاستدعاء - data Sorry, option copyrighttext was not found



getAvatars

يمكنك من جلب قائمة بالصور الرمزية

البارميترز المطلوبة

الوصف البارام
لا يوجد لا يوجد

مثال الاستدعاء الخارجي

						
						$postfields["action"] = "getAvatars";
						$postfields["datatype"] = "json";
						
					

مثال الاستدعاء الداخلي

						
$action = "getAvatars";
$values = array();
$values["datatype"] = "json";

$data = localAPI($action, $values);
						
					

القيمة الناتجة في حالة النجاح

الوصف القيمة
نتيجة الاستدعاء - result success
مصفوفة من الصور الرمزية - data
						
						array(
								0 => array
									(
										"avatarid" => 1,
										"avatarname" => "title",
										"avatarpath" => "http://www.mydomain.com/contents/avatars/1.jpg"
									),
								1 => array
									(
										"avatarid" => 2,
										"avatarname" => "title2",
										"avatarpath" => "http://www.mydomain.com/contents/avatars/2.jpg"
									)
							 )

القيمة الناتجة في حالة الفشل

الوصف القيمة
نتيجة الاستدعاء - result error
رسالة الخطأ المعادة من الاستدعاء - data Sorry, No avatars found in database



getModules

يمكنك من جلب قائمة بالموديولات المفعلة

البارميترز المطلوبة

الوصف البارام
لا يوجد لا يوجد

مثال الاستدعاء الخارجي

						
						$postfields["action"] = "getModules";
						$postfields["datatype"] = "json";
						
					

مثال الاستدعاء الداخلي

						
$action = "getModules";
$values = array();
$values["datatype"] = "json";

$data = localAPI($action, $values);
						
					

القيمة الناتجة في حالة النجاح

الوصف القيمة
نتيجة الاستدعاء - result success
مصفوفة من الموديولات - data

								array(
									0 => array(
										"module" => "news",
										"name" => "الأخبار",
									),
									1 => array(
										"module" => "album",
										"name" => "ألبوم الصور",
									)
								)

القيمة الناتجة في حالة الفشل

الوصف القيمة
نتيجة الاستدعاء - result error
رسالة الخطأ المعادة من الاستدعاء - data Sorry, No modules found in database



getModuleSections

يمكنك من جلب قائمة بأقسام موديول

البارميترز المطلوبة

الوصف البارام
اسم الموديول modulename

مثال الاستدعاء الخارجي

						
						$postfields["action"] = "getModuleSections";
						$postfields["datatype"] = "json";
						$postfields["modulename"] = "news";
						
					

مثال الاستدعاء الداخلي

						
$action = "getModuleSections";
$values = array();
$values["datatype"] = "json";
$values["modulename"] = "news";

$data = localAPI($action, $values);
						
					

القيمة الناتجة في حالة النجاح

الوصف القيمة
نتيجة الاستدعاء - result success
مصفوفة من الأقسام - data

								array(
									0 => array(
										'id' => 1,
                            'mother' => 1,
                            'name' => "الأخبار المحلية",
                            'description' => "أخبار محلية بكافة المجالات",
                            'picture' => "1.jpg",
                            'last_add' => "1409829780",
                            'numf' => "533",
                            'metad' => "أخبار محلية",
                            'metak' => "أخبار,أخبار محلية,مناطق,وزارات",
                            'active' => 1
									),
									1 => array(
										'id' => 2,
                            'mother' => 1,
                            'name' => "الأخبار الدولية",
                            'description' => "أخبار دولية في كافة المجالات",
                            'picture' => "2.jpg",
                            'last_add' => "1409231520",
                            'numf' => "215",
                            'metad' => "أخبار دولية",
                            'metak' => "أخبار,أخبار دولية",
                            'active' => 1
									)
								)

القيمة الناتجة في حالة الفشل

الوصف القيمة
نتيجة الاستدعاء - result error
رسالة الخطأ المعادة من الاستدعاء - data Sorry, No sections found in database



getPlugins

يمكنك من جلب قائمة بالبلجنات

البارميترز المطلوبة

الوصف البارام
لا يوجد لا يوجد

مثال الاستدعاء الخارجي

						
						$postfields["action"] = "getPlugins";
						$postfields["datatype"] = "json";
						
					

مثال الاستدعاء الداخلي

						
$action = "getPlugins";
$values = array();
$values["datatype"] = "json";

$data = localAPI($action, $values);
						
					

القيمة الناتجة في حالة النجاح

الوصف القيمة
نتيجة الاستدعاء - result success
مصفوفة من البلجنات - data

								array(
									0 => array(
										'id' => 5,
    'active' => 1,
    'name' => 'Album',
    'description' => 'The Album Module Allow You To Manage Your Photos.',
    'author' => 'Dimofinf',
    'version' => '1.0.1',
    'is_module' => true,
    'logo' => true,
    'section_table' => 'albums',
    'content_table' => 'albumsm',
    'folder' => 'album',
									),
									1 => array(
										'id' => 8,
    'active' => 1,
    'name' => 'Article',
    'description' => 'The article module allow you to manage your articles.',
    'author' => 'Dimofinf',
    'version' => '1.0.1',
    'is_module' => true,
    'logo' => true,
    'section_table' => 'articles',
    'content_table' => 'articlesm',
    'folder' => 'article'
									)
								)

القيمة الناتجة في حالة الفشل

الوصف القيمة
نتيجة الاستدعاء - result error
رسالة الخطأ المعادة من الاستدعاء - data Sorry, No plugins found in database



getSmilies

يمكنك من جلب قائمة بالابتسامات

البارميترز المطلوبة

الوصف البارام
لا يوجد لا يوجد

مثال الاستدعاء الخارجي

						
						$postfields["action"] = "getSmilies";
						$postfields["datatype"] = "json";
						
					

مثال الاستدعاء الداخلي

						
$action = "getSmilies";
$values = array();
$values["datatype"] = "json";

$data = localAPI($action, $values);
						
					

القيمة الناتجة في حالة النجاح

الوصف القيمة
نتيجة الاستدعاء - result success
مصفوفة من الابتسامات - data

								array(
									0 => array(
										'smilieid' => '2',
    'title' => 'Confused',
    'smilietext' => ':confused:',
    'smiliepath' => 'confused.gif',
									),
									1 => array(
										'smilieid' => '3',
    'title' => 'Cool',
    'smilietext' => ':cool:',
    'smiliepath' => 'cool.gif',
									)
								)

القيمة الناتجة في حالة الفشل

الوصف القيمة
نتيجة الاستدعاء - result error
رسالة الخطأ المعادة من الاستدعاء - data Sorry, No smilies found in database



getUsergroups

يمكنك من جلب قائمة بمجموعات العضوية

البارميترز المطلوبة

الوصف البارام
لا يوجد لا يوجد

مثال الاستدعاء الخارجي

						
						$postfields["action"] = "getUsergroups";
						$postfields["datatype"] = "json";
						
					

مثال الاستدعاء الداخلي

						
$action = "getUsergroups";
$values = array();
$values["datatype"] = "json";

$data = localAPI($action, $values);
						
					

القيمة الناتجة في حالة النجاح

الوصف القيمة
نتيجة الاستدعاء - result success
مصفوفة من المجموعات - data

								array(
									0 => array(
									'usergroupid' => '4',
    'title' => 'Members',
    'description' => '',
    'usertitle' => 'Member',
    'opentag' => '',
    'closetag' => ''
									),
									1 => array(
										'usergroupid' => '5',
    'title' => 'Authors',
    'description' => '',
    'usertitle' => 'Author',
    'opentag' => '',
    'closetag' => '',
									)
								)

القيمة الناتجة في حالة الفشل

الوصف القيمة
نتيجة الاستدعاء - result error
رسالة الخطأ المعادة من الاستدعاء - data Sorry, you do not have permission to get usergroups


للأعلى | العودة