Path not found on PodioAppField::update - php

I am following the documentation https://developers.podio.com/doc/applications
and the given models from the SDK.
Im trying to add a new app to an existing app reference like so:
$attributes = array(
"referenced_apps" => array(ref_app_id1 , ref_app_id2)
);
PodioAppField::update( 123 , 'my_external_id' ,array (
"settings" => $attributes
));
But will receive the following error
Uncaught PodioNotFoundError: "No matching operation could be found. The path '/app/123/field/my_external_id' was not found.."
My app_id and external_id are correct.
TIA

It requires field_id instead of external_id.

Related

Podio PHP - PodioItem: Add option to category field

I am trying to add a new option to PodioCategoryItemField using the podio php api
$field = new \PodioCategoryItemField('test');
$field->add_value( array(
'value'=>array( 'status'=>'active','text' =>'some label','color'=>'#FFF' )
));
I can't get it to work. I have to set an id in the array, but if I do, I get an error that the option is not valid ( offcourse, I try to create a new one )
Any ideas on this?

Active Collab API: How to get projects

I'm trying out the ActiveCollab API for my first time. I had to use StackOveflow to figure out how to get the API token since the docs don't tell me this.
Below is my code:
/* GET INTENT */
$url = 'https://my.activecollab.com/api/v1/external/login';
$fields = array(
'email' => "email#email.com",
'password' => "****"
);
$intent = curl_post_connector($url, $fields);
$intent = $intent->user->intent;
/* GET TOKEN */
$url = 'https://app.activecollab.com/my_app_id/api/v1/issue-token-intent';
$fields = array(
'intent' => $intent,
'client_name' => 'My App Name',
'client_vendor' => 'My Company Name'
);
$token = curl_post_connector($url, $fields);
$token = $token->token;
Everything above works and get's the token properly. What I find really weird is that I have to use API v1 to get this, and the docs on ActiveCollab's site don't mention any URL for API v5. It seems like this is the approach everything is taking here on StackOverflow.
Now with the token, I try to get my list of projects:
/* GET PROJECT */
$url = 'https://app.activecollab.com/my_app_id/api/v1/users';
$headers = array (
"X-Angie-AuthApiToken" => $token
);
$projects = curl_get_connector($url, $headers);
var_dump($projects);
But this does not work. There is no error returned - it instead returns an array of languages for some reason! I don't want to paste the massive json object here, so instead I'll link you to a photo of it: https://www.screencast.com/t/7p5JuFB4Gu
UPDATE:
When attempting to use the SDK, it works up until I try getting the token (which is just as far as I got without the SDK). I'm getting Server Error 500, and when looking at the logs, it says:
/home/working/public_html/ac/index.php(21): ActiveCollab\SDK\Authenticator\Cloud->issueToken(123456789)
#1 {main}
thrown in /home/working/public_html/ac/SDK/Authenticator/Cloud.php on line 115
This is line 115 of Cloud.php:
throw new InvalidArgumentException("Account #{$account_id} not loaded");
I honestly don't think I did anything wrong... there must be something wrong with my account ID.
Just for kicks, I commented out that line, and the error disappears and the page loads fine - except now I have no token...

How to get list of campaigns in Facebook Marketing API using PHP

an advanced thank you for taking time answering this.
I would like to retrieve all of my campaign list in facebook marketing API.
this is my code:
use FacebookAds\Object\AdUser;
use FacebookAds\Object\AdAccount;
use FacebookAds\Object\Fields\AdAccountFields;
use FacebookAds\Object\Campaign;
use FacebookAds\Object\AdCampaign;
use FacebookAds\Object\Fields\CampaignFields;
use FacebookAds\Object\Fields\AdCampaignFields;
use FacebookAds\Object\Fields\AdsInsightsFields;
use FacebookAds\Object\Fields\AdSetFields;
$account = new AdAccount($account_id);
$params = array(
'time_interval' => array(
'day_start' => array('year' =>'2015', 'month'=> '5', 'day'=>'1'),
'day_stop' => array( 'year'=>'2015', 'month'=>'5', 'day'=>'31')
),
'limit' => 500,
);
$fields = array(
AdCampaignFields::NAME, /* <--- this is the error */
AdCampaignFields::OBJECTIVE,
AdCampaignFields::STATUS,
);
$campaigns = $account->getAdCampaigns($fields,$params);
print_r($campaigns);
Now there are no result shown instead there's an error:
[14-Feb-2017 01:26:55 UTC] PHP Fatal error: Class 'FacebookAds\Object\Fields\AdCampaignFields' not found in /home/rbadmin17/public_html/test_17/index.php on line 98
I already call the "AdCampaignFields" and still it says Class not found.
Thanks for the help...
Your code looks correct but the class AdCampaignFields doesn't yet exist in the up to date SDK and was replaced by CampaignFields class (which isn't actually needed for your code).
Your code should work just by removing the line :
use FacebookAds\Object\Fields\AdCampaignFields;
Edit: in fact some examples of the FB doc are deprecated. Just take a look in the SDK folders to see by yourself when you get this kind of error. Sometimes it's just a class name which have been changed.

Get userId on database in Silex Project

I started a new project with Silex, it looks like a cool and fast Framework but I'm getting crazy with the SecurityServiceProvider trying to get the uid. I though it should be something like the getId() like Symfony but I got an error that the function doesn't exists.
PHP Fatal error: Call to undefined method Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage::getUser()
If I got the current logged user I have his information but not the Id.
$user = $app['user'];
print_r($user);
Symfony\Component\Security\Core\User\User Object (
[username:Symfony\Component\Security\Core\User\User:private] =>
myuser#mymail.com
[password:Symfony\Component\Security\Core\User\User:private] =>
5FZ2Z8QIkA7UTZ4BYkoC+GsReLf569mSKDsfods6LYQ8t+a8EW9oaircfMpmaLbPBh4FOBiiFyLfuZmTSUwzZg==
[enabled:Symfony\Component\Security\Core\User\User:private] => 1
[accountNonExpired:Symfony\Component\Security\Core\User\User:private]
=> 1 [credentialsNonExpired:Symfony\Component\Security\Core\User\User:private]
=> 1 [accountNonLocked:Symfony\Component\Security\Core\User\User:private]
=> 1 [roles:Symfony\Component\Security\Core\User\User:private] => Array ( [0] => ROLE_USER ) )
Any idea? Thanks in advance!
// Symfony 2.6+
$token = $app['security.token_storage']->getToken();
// Symfony 2.3/2.5
$token = $app['security']->getToken();
Get user info:
$user = $token->getUser();
Check $user
var_dump($user);
Ok got the solution, if anybody implements a new UserProvider, should to add the customs fields on the provider, and define them on User class in Symfony. Thanks anyway!

Invalid Api key using RestServer

I am using the codeigniter rest server api library.
When I enter http://localhost/projects/myapi/key/index_put.php and hit enter gives me the following error:
<xml>
<status>0</status>
<error>Invalid API Key</error>
</xml>
When I give a dummy string in the url, like:
http://localhost/projects/myapi/key/index_put.php?X-API-KEY=asldfj9alsdjflja97979797997
I get the same problem. Any idea?
index_put.php:
public function index_put() {
// Build a new key
$key = self::_generate_key();
// If no key level provided, give them a rubbish one
$level = $this->put('level') ? $this->put('level') : 1;
$ignore_limits = $this->put('ignore_limits') ? $this->put('ignore_limits') : 1;
// Insert the new key
if (self::_insert_key($key, array('level' => $level, 'ignore_limits' => $ignore_limits))) {
$this->response(array('status' => 1, 'key' => $key), 201); // 201 = Created
} else {
$this->response(array('status' => 0, 'error' => 'Could not save the key.'), 500); // 500 = Internal Server Error
}
}
i faced the same issue .don't mention put/get/post in URL ,RestServer itself recognizes the request nature base on parameter you pass two step required to solve your problem .
1st Step :
http://localhost/projects/myapi/key/index_put.php
must change to :
http://localhost/projects/myapi/key/index.php
2nd step:
create an api kay using sha1(max 40 character) in the keys table (table structure show in config/rest.php file),
enter 1 in is_private_key field and ::1 in ip_address field.
create the record ,and check it again .
This question is old but for those who finds this, the answer is:
The library https://github.com/chriskacerguis/codeigniter-restserver when using PUT method, the API KEY should be in the put header variables as x-www-form-urlencoded type.
Use google chrome postman and fill like image below:

Categories