Esempio n. 1
0
<?php

require '../src/meli.php';
// Create our Application instance (replace this with your appId and secret).
$meli = new Meli(array('appId' => 'MeliPHPAppId', 'secret' => 'MeliPHPSecret'));
$userId = $meli->initConnect();
// Login or logout url will be needed depending on current user state.
if ($userId) {
    if (isset($_REQUEST['question_id']) == 1) {
        $response = $meli->postWithAccessToken('/answers', array('question_id' => $_REQUEST['question_id'], 'text' => $_REQUEST['answer_text']));
        $_SESSION['answer_question'] = true;
        header("Location: " . $meli->getCurrentUrl(), TRUE, 302);
    }
    $user = $meli->getWithAccessToken('/users/me');
    $unansweredQuestions = $meli->getWithAccessToken('/questions/search', array('seller' => $user['json']['id'], 'status' => 'UNANSWERED'));
}
?>
<!doctype html>
<html>
<head>
	<meta charset="UTF-8"/>
	<title>MeliPHP SDK - Example questions</title>
</head>
<body>
	
	<h1>MeliPHP SDK - Example questions</h1>
	<?php 
if ($userId) {
    ?>
		<p>Hello <?php 
    echo $user['json']['first_name'];