Other Hỏi auto post xenforo 2 = php

aathuat

Private
Tham gia
15/05/2017
Bài viết
15
Được Like
7
Như title mình có tham khảo bài https://xenforo.com/community/threads/xenforo_datawriter-to-create-post-in-xf2.140853/
Mã:
<?php
$dir = "/home/vvvbb/public_html/domain/xxxx.org";
require($dir . '/src/XF.php');
XF::start($dir);

$forumId = 68;  //Forum ID of where to post thread
$userId = 6;  //User ID # of account to post thread as
$title = "CONTENTS OF TITLE";
$message = 'CONTENTS OF POST Message';

$forum = \XF::em()->find('XF:Forum', $forumId);
$user = \XF::em()->find('XF:User', $userId);
\XF::asVisitor($user, function() use ($forum, $title, $message)
{
    $creator = \XF::service('XF:Thread\Creator', $forum);
    $creator->setContent($title, $message);
    $creator->setPrefix('1');  //Prefix ID # to set new thread as.
    $creator->setIsAutomated();
    $creator->save();
});
và dùng xen2 nhưng khi run php thì lỗi
PHP Parse error: syntax error, unexpected '$dir' (T_VARIABLE) in /home/.... ở dòng 1
Đường dẫn mình đã sửa ok mà vẫn ko đc
ko biết có bạn nào thử chưa ?
 

Win

MasterCorporal
Tham gia
15/02/2016
Bài viết
378
Được Like
171
Như title mình có tham khảo bài https://xenforo.com/community/threads/xenforo_datawriter-to-create-post-in-xf2.140853/
Mã:
<?php
$dir = "/home/vvvbb/public_html/domain/xxxx.org";
require($dir . '/src/XF.php');
XF::start($dir);

$forumId = 68;  //Forum ID of where to post thread
$userId = 6;  //User ID # of account to post thread as
$title = "CONTENTS OF TITLE";
$message = 'CONTENTS OF POST Message';

$forum = \XF::em()->find('XF:Forum', $forumId);
$user = \XF::em()->find('XF:User', $userId);
\XF::asVisitor($user, function() use ($forum, $title, $message)
{
    $creator = \XF::service('XF:Thread\Creator', $forum);
    $creator->setContent($title, $message);
    $creator->setPrefix('1');  //Prefix ID # to set new thread as.
    $creator->setIsAutomated();
    $creator->save();
});
và dùng xen2 nhưng khi run php thì lỗi
PHP Parse error: syntax error, unexpected '$dir' (T_VARIABLE) in /home/.... ở dòng 1
Đường dẫn mình đã sửa ok mà vẫn ko đc
ko biết có bạn nào thử chưa ?


Có vẻ lỗi ngay tại dòng đầu tiên. Bạn dùng thử API Post thread xem
upload_2019-2-28_13-8-49.png
 

aathuat

Private
Tham gia
15/05/2017
Bài viết
15
Được Like
7
@Win cho mình hỏi sử dụng APi có thể auto post đc ko ^^
Bạn có post nào hd sử dụng API ko cho mình xin
thanks
 
  • Like
Reactions: Win

vipkhongtin

Private
Tham gia
13/04/2015
Bài viết
40
Được Like
14
Như title mình có tham khảo bài https://xenforo.com/community/threads/xenforo_datawriter-to-create-post-in-xf2.140853/
Mã:
<?php
$dir = "/home/vvvbb/public_html/domain/xxxx.org";
require($dir . '/src/XF.php');
XF::start($dir);

$forumId = 68;  //Forum ID of where to post thread
$userId = 6;  //User ID # of account to post thread as
$title = "CONTENTS OF TITLE";
$message = 'CONTENTS OF POST Message';

$forum = \XF::em()->find('XF:Forum', $forumId);
$user = \XF::em()->find('XF:User', $userId);
\XF::asVisitor($user, function() use ($forum, $title, $message)
{
    $creator = \XF::service('XF:Thread\Creator', $forum);
    $creator->setContent($title, $message);
    $creator->setPrefix('1');  //Prefix ID # to set new thread as.
    $creator->setIsAutomated();
    $creator->save();
});
và dùng xen2 nhưng khi run php thì lỗi
PHP Parse error: syntax error, unexpected '$dir' (T_VARIABLE) in /home/.... ở dòng 1
Đường dẫn mình đã sửa ok mà vẫn ko đc
ko biết có bạn nào thử chưa ?
Em chạy thì dính lỗi này. bác thớt fix đc chưa vậy>
An unexpected error occurred. Please try again later.
 

Hướng dẫn sử dụng

XenForo 1 XenForo 2
Translate by PVS

Dịch vụ XenForo của VNXF

Mr. Tuấn

Mobile/Zalo: 0988 488 096

Telegram: bluekpro

Email: [email protected]

Nhà Tài Trợ

Mút Xốp Không Gian
pallet Thịnh Phát
Top Bottom