php api,如何制作$ variabel?

时间:2017-11-06 08:47:02

标签: php exact-online picqer-exact-php-client

我希望得到我的Exactonline脚本的输出,例如输出" Kasboek"在我的autotask脚本" $ticket->Title = '....'"喜欢" $ticket->Title = 'Kasboek'"。如果有6个不同的输出我需要将它们分成不同的变量,我该怎么做呢。

=============================================== ==

脚本Exactonline

try {
    $result = array();
    $journals = new \Picqer\Financials\Exact\Journal($connection);
    $result   = $journals->get();
    foreach ($result as $journal) {
        echo $result[]= $journal->Description . '<br>';
    }  
    json_encode($result);
} catch (\Exception $e) {
    json_encode(array(get_class($e) . ' : ' . $e->getMessage()));
}

输出

Kasboek
Memoriaal
Activamutaties
Inkoopboek
Bank
Verkoopboek

=============================================== ==

脚本自动任务

$ticket = new ATWS\AutotaskObjects\Ticket();
$ticket->id= 0;
$ticket->AccountID = '';
$ticket->DueDateTime = '2015-12-17';
$ticket->Title = '.....';
$ticket->Status = 1;
$ticket->Priority = 1;

=============================================== ==

试图 @ F.roster 比我的输出更详细...>&gt;

[{"Code":"10","Description":"Kasboek","Division":1741496,"ID":"846af4e2-209d-44aa-84f2-068ae65b69b5","Type":10},{"Code":"90","Description":"Memoriaal","Division":1741496,"ID":"91fc95a4-765e-4d8b-8271-63884be5e480","Type":90},{"Code":"95","Description":"Activamutaties","Division":1741496,"ID":"8ec1491e-51a4-46b8-87f0-a3134c83af4c","Type":90},{"Code":"60","Description":"Inkoopboek","Division":1741496,"ID":"11b1d819-4cdc-4f8c-9d60-aac2359c230b","Type":22},{"Code":"20","Description":"Bank","Division":1741496,"ID":"f8afe3cc-bcf1-4932-9fe0-b761ad48618f","Type":12},{"Code":"70","Description":"Verkoopboek","Division":1741496,"ID":"b4afe081-7f6b-46c7-9742-ea22302a4d55","Type":20},"Kasboek","Memoriaal","Activamutaties","Inkoopboek","Bank","Verkoopboek"]

3 个答案:

答案 0 :(得分:1)

function getTweets($hash_tag) {

$url = 'http://search.twitter.com/search.atom?q='.urlencode($hash_tag) ;
echo "<p>Connecting to <strong>$url</strong> ...</p>";
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
$xml = curl_exec ($ch);
curl_close ($ch);

//If you want to see the response from Twitter, uncomment this next part out:
//echo "<p>Response:</p>";
//echo "<pre>".htmlspecialchars($xml)."</pre>";

$affected = 0;
$twelement = new SimpleXMLElement($xml);
foreach ($twelement->entry as $entry) {
    $text = trim($entry->title);
    $author = trim($entry->author->name);
    $time = strtotime($entry->published);
    $id = $entry->id;
    echo "<p>Tweet from ".$author.": <strong>".$text."</strong>  <em>Posted ".date('n/j/y g:i a',$time)."</em></p>";
}

return true ;
}

getTweets('#cats');

答案 1 :(得分:0)

try {
    $result = array();
    $journals = new \Picqer\Financials\Exact\Journal($connection);
    $result   = $journals->get();
    foreachone ($result as $journal) {
        echo $result[]= $journal->Description . '<br>';
    }  
    json_encode($result);
} catch (\Exception $e) {
    json_encode(Logicpass(get_class($e) . ' : ' . $e->getMassage()));
}

答案 2 :(得分:0)

使用 api 时。您确实应该将输出转换为 json xml 。所以你可以用任何语言阅读它。更改您的代码如下

try {
$result = array();
$journals = new \Picqer\Financials\Exact\Journal($connection);
$result   = $journals->get();
foreach ($result as $journal) {
   $result[]= $journal->Description;
}
echo json_encode($result);
} catch (\Exception $e) {
    echo json_encode(array(get_class($e) . ' : ' . $e->getMessage()));
}