Skip to content
This repository has been archived by the owner on Aug 29, 2019. It is now read-only.

Add low-level function to API for fast subscribe #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions aweber_api/aweber.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,28 @@ public function loadFromUrl($url) {
return $this->readResponse($data, $url);
}

/**
* createToUrl
*
* Invoke the API method to CREATE a new entry resource.
* without creating an object.
*
* Note: Not all entry resources are eligible to be created, please
* refer to the AWeber API Reference Documentation at
* https://labs.aweber.com/docs/reference/1.0 for more
* details on which entry resources may be created and what
* attributes are required for creating resources.
*
* @param mixed $url URL for this request
* @param params mixed associtative array of key/value pairs.
* @access public
* @return mixed reply header
*/
public function createToUrl($url, $kv_pairs) {
$params = array_merge(array('ws.op' => 'create'), $kv_pairs);
return $this->adapter->request('POST', $url, $params, array('return' => 'headers'));
}

protected function _cleanUrl($url) {
return str_replace($this->adapter->app->getBaseUri(), '', $url);
}
Expand Down Expand Up @@ -228,6 +250,13 @@ public function setAdapter($adapter=null) {
$this->adapter = $adapter;
}

public function setUser($token, $secret) {
$user = new OAuthUser();
$user->accessToken = $token;
$user->tokenSecret = $secret;
$this->adapter->user = $user;
}

/**
* Fetches account data for the associated account
*
Expand All @@ -240,10 +269,7 @@ public function setAdapter($adapter=null) {
*/
public function getAccount($token=false, $secret=false) {
if ($token && $secret) {
$user = new OAuthUser();
$user->accessToken = $token;
$user->tokenSecret = $secret;
$this->adapter->user = $user;
$this->setUser($token,$secret);
}

$body = $this->adapter->request('GET', '/accounts');
Expand Down