Closed emerika closed 9 years ago
// initializing WeeblyClient with $client_id, $client_secret, $user_id, $site_id, $authorization_code
// $authorization_code is the value you get at the end of the oauth process
// it is the base 64 encoding of "access_code-user_id"
$weebly = new \Weebly\WeeblyClient($client_id, $client_secret, $user_id, $site_id, $authorization_code);
// fetch webhooks via api
$webhooks = $weebly->get('/webhooks');
echo "Webhooks:<pre>".var_export($webhooks, true)."</pre>";
Thanks -- so the oauth process must complete before you can use this?
Yes, you would need to get the authorization code to include in the constructor.
Once that is set, you can make any calls you're server has been scoped for.
To be clear, are we talking the 'token' you get after the oauth process is done? Or the 'authorization_code' you get during the auth process? I have gotten through the auth process, have a token and am trying to move on to editing store items'
The access token at the end of the oauth process.
Should this work for reading store information like this?
$wc = new \Weebly\WeeblyClient($CLIENT_ID, $API_SECRET, $auth[ 'user_id'], $auth['site_id'], $auth['token']);
$wc->get('/58912207/sites/448071555340782742/store');
You would use:
$wc->get('/user/sites/448071555340782742/store');
User ID is already part of the request as per the auth token.
Does i make sense for me to make these changes?
const WEEBLY_DOMAIN = 'http://api.weebly.com/';
const WEEBLY_API_DOMAIN = 'http://api.weebly.com//v1';
The call above no longer fails, but seems to return nothing.
I made the above changes and:
removed the extra slash in WEEBLY_API_DOMAIN.
and $wc->get('/user/sites/448071555340782742/store');
takes a long time (10 seconds?) but returns a NULL. Any thoughts?
WEEBLY_DOMAIN should be https://www.weebly.com and WEEBLY_API_DOMAIN should be https://api.weebly.com/v1
The https is important for the API.
Thank you. That solved my problem.
DO you have a simple example of using this class?