i want to exclude some mention users while sending the tweet so i mentioned in the code as exclude_reply_user_ids and passing this parameter to /statuses/update.json. But still i cant exclude users after tweeting reply.
So Here is my code :
$params = array(
'status' => $message,
'auto_populate_reply_metadata' => 'true',
'tweet_mode' => 'extended',
'in_reply_to_status_id' => $status_id,
'in_reply_to_screen_name' => $screenname,
'exclude_reply_user_ids' => $exids
);
$res = $tmhOAuth->request('POST', $config->twitter_api_url . '/statuses/update.json',
$params,
true,
true
);
[output][1]
[output][2]
[output][3]
[output][4]
[output][5]
[1]: https://i.stack.imgur.com/Yfmvs.png
[2]: https://i.stack.imgur.com/zUMx2.png
[3]: https://i.stack.imgur.com/VfzEL.png
[4]: https://i.stack.imgur.com/9XQYr.png
[5]: https://i.stack.imgur.com/z3QCy.png
Related
i'm try to write dailymotion api upload php code
i'm use example code from https://developer.dailymotion.com/guides
it's work great
and i want add Geoblocking only allow Japan
this is my code
require_once 'Dailymotion.php';
// Account settings
$apiKey = 'xxxxxxxxxxxxxxxxxx';
$apiSecret = 'xxxxxxxxxxxxxxxxxx';
$testUser = 'xxxxxxxxxxxxxxxxxx#xxxx.com';
$testPassword = 'xxxxxxxxxxxxxxxxxx';
$videoTestFile = 'C:/output.mp4';
// Scopes you need to run your tests
$scopes = array(
'userinfo',
'feed',
'manage_videos',
);
// Dailymotion object instanciation
$api = new Dailymotion();
$api->setGrantType(
Dailymotion::GRANT_TYPE_PASSWORD,
$apiKey,
$apiSecret,
$scopes,
array(
'username' => $testUser,
'password' => $testPassword,
)
);
$url = $api->uploadFile($videoTestFile);
$result = $api->post(
'/videos',
array(
'url' => $url,
'title' => 'Dailymotion PHP SDK upload test 2',
'tags' => 'dailymotion,api,sdk,test',
'channel' => 'videogames',
'published' => true,
'geoblocking' => 'JP', // i'm add this line
)
);
var_dump($result);
but i got this error
Fatal error: Uncaught exception 'DailymotionAuthRequiredException' with message 'Insufficient rights for the `geoblocking' parameter of route `POST /videos'. Required scopes: manage_videos'
anyone can tell me
what i'm doing wrong and help me fix this problem
thank you
'geoblocking' => 'JP'
change to 'geoblocking' => 'jp'
your code will be
require_once 'Dailymotion.php';
// Account settings
$apiKey = 'xxxxxxxxxxxxxxxxxx';
$apiSecret = 'xxxxxxxxxxxxxxxxxx';
$testUser = 'xxxxxxxxxxxxxxxxxx#xxxx.com';
$testPassword = 'xxxxxxxxxxxxxxxxxx';
$videoTestFile = 'C:/output.mp4';
// Scopes you need to run your tests
$scopes = array(
'userinfo',
'feed',
'manage_videos',
);
// Dailymotion object instanciation
$api = new Dailymotion();
$api->setGrantType(
Dailymotion::GRANT_TYPE_PASSWORD,
$apiKey,
$apiSecret,
$scopes,
array(
'username' => $testUser,
'password' => $testPassword,
)
);
$url = $api->uploadFile($videoTestFile);
$result = $api->post(
'/videos',
array(
'url' => $url,
'title' => 'Dailymotion PHP SDK upload test 2',
'tags' => 'dailymotion,api,sdk,test',
'channel' => 'videogames',
'published' => true,
'geoblocking' => 'jp' // NO , in last line
)
);
var_dump($result);
Trying to send pushed at the users local time, not to disturb them.
Need to send push notification at users local time.
The Notification are sent not often with status of their gameplay, I am very aware not to spam users.
Class Helper {
function pwCall( $action, $data = array() ) {
$url = 'https://cp.pushwoosh.com/json/1.3/' . $action;
$json = json_encode( array( 'request' => $data ) );
$res = helper::doPostRequest( $url, $json, 'Content-Type: application/json' );
#json_decode( $res, true );
}
helper::pwCall( 'createMessage', array(
'application' => PW_APPLICATION,
'auth' => PW_AUTH,
'notifications' => array(
array(
'send_date' => 'now',
'content' => array('en' => "..your turn to play.",
'fr' => "..votre tour de jouer",
),
'ios_badges' => $row->count,
'devices' => array($pushToken),
'data' => array( 'custom' => 'json data' )
)
)
)
);
Need to replace 'now' with 12:30pm or 13:30 ( military time )
You should put (example):
send_date => "2014-04-01 12:30",
ignore_user_timezone => false
Make sure you schedule notification at least 24 hours in advance if you use Timezeones.
Actually, in order to send a notification according to your users' time zones, all you need is to add the following line in your request:
'ignore_user_timezone' => false,
Then, you can specify the preferred time in 'send_date' section with the format "YYYY-MM-DD HH:mm". Military time would work just fine.
I used the following code to try to grab tweets from my home_timeline
$tmhOAuth = new tmhOAuth(array('consumer_key' => TW_KEY,
'consumer_secret' => TW_SECRET,
'user_token' => TW_UTOKEN,
'user_secret' => TW_USECRET,
));
$code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/home_timeline', 'json'));
The $tmhOAuth came from this library here: https://github.com/themattharris/tmhOAuth
For some reason, only one tweet is showing, and it's my most recent one. All my old tweets are not visible. When I change the secrets and keys to that of another user-app, i have similar problme, some tweets are visible while others are not. Does anyone know why it doesnt' just grab all X number of the most recent tweets? Why are some tweets missing?
I download Jimbo's API from github and then did hte following code
<?php
ini_set('display_errors', 1);
require_once('twjimbo/TwitterAPIExchange.php');
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
'oauth_access_token' => "",
'oauth_access_token_secret' => "",
'consumer_key' => '',
'consumer_secret' => ""
);
]
$url = 'https://api.twitter.com/1.1/statuses/home_timeline.json';
$getfield = '?screen_name=anythingworkshere';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$json = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
echo '<pre>'; print_r(json_decode($json)); echo '</pre>';
Here’s my widget in the Form.Class:
$this->widgetSchema['schools'] = new sfWidgetFormChoice(array(
'choices' => Doctrine_Core::getTable('school')->getUsersSchools($userId),
'renderer_class' => 'sfWidgetFormSelectDoubleList',
'renderer_options' => array(
'label_unassociated' => 'Unassociated',
'label_associated' => 'Associated'
)));
The above works just fine, but the values that are stored are unassociated to the choices list referenced above. I need to store the ids of the array retrieved as the values. Instead, the list that is retrieved is chronological and the ids are ignored.
Here's the schoolTable query:
public function getUsersSchools($id){
$q =Doctrine_Query::create()
->select('id')
->from('school')
->where('user_id = ?', $id)
->execute();
return $q;
}
If I understand your question correctly you would like to store associated school ids.
Use the sfWidgetFormDoctrineChoice widget instead and it will work out of the box, as it using primary keys as ids.
$query = Doctrine_Core::getTable('school')->queryForSelect($userId);
$this->setWidget('schools', new sfWidgetFormDoctrineChoice(array(
'model' => 'school',
'query' => $query,
'multiple' => true,
'renderer_class' => 'sfWidgetFormSelectDoubleList',
'renderer_options' => array(
'label_unassociated' => 'Unassociated',
'label_associated' => 'Associated'
),
)));
$this->setValidator('schools', new sfValidatorDoctrineChoice(array(
'model' => 'schoool',
'query' => $query,
'multiple' => true,
)));
// in SchoolTable class
public function queryForSelect($userId)
{
return $this->createQuery('s')
->andWhere('s.user_id = ?', $userId)
;
}
If you has a proper schema (I presume the schools should be a many-to-many association), then the current from should has a schools_list field (properly defined in the generated base from) and then you can modify that field to be rendered by sfWidgetFormSelectDoubleList:
$this->widgetSchema['schools_list']->setOption('renderer_class', 'sfWidgetFormSelectDoubleList');
$this->widgetSchema['schools_list']->setOption('renderer_options', array(
'label_unassociated' => 'Unassociated',
'label_associated' => 'Associated'
));
My models association chain:
ArchitectPurchase belongsTo ArchitectProfile belongsTo User
My action:
$this->ArchitectPurchase->recursive = -1;
$this->ArchitectPurchase->Behaviors->attach('Containable');
$this->paginate['joins'] = array(
array(
'table' => 'architect_profiles',
'alias' => 'ArchitectProfileJoin',
'type' => 'inner',
'conditions' => array(
'ArchitectProfileJoin.id = ArchitectPurchase.architect_profile_id'
)
),
array(
'table' => 'users',
'alias' => 'User',
'type' => 'inner',
'conditions' => array(
'User.id = ArchitectProfileJoin.user_id'
)
)
);
$this->paginate['order'] = 'User.name DESC';
$this->paginate['contain'] = array(
'ArchitectProfile' => array(
'fields' => array('ArchitectProfile.id'),
'User' => array(
'fields' => array('User.name')
)
)
);
$this->set('architectPurchases', $this->paginate());
This action works fine, ordering the results by User.name DESC. But when I use the link created with
echo $this->Paginator->sort('User.name')
in my view, it does not work!
Looking at the core files, I found that the validateSort method of the PaginatorComponent was the problem:
if ($object->hasField($field)) {
$order[$alias . '.' . $field] = $value;
} elseif ($object->hasField($key, true)) {
$order[$field] = $value;
} elseif (isset($object->{$alias}) && $object->{$alias}->hasField($field, true)) {
$order[$alias . '.' . $field] = $value;
}
As the User model is not directly associated with the ArchitectPurchase model, I get
$order = array()
instead of
$order = array('User.name' => 'asc')
I tried to use the $whitelist parameter, but still not working...
So I had to hack the core (noooo!!!), commenting from line 345 to 363 to make it work.
Am I doing something wrong or is this a 2.2.1 issue?
Thanks for posting this, I was actually having the same issue and with your insight of the problem I was able to solve it.
I posted a ticket on the issue tracker of CakePHP if anyone is interested, but basically they said it won't be fixed and offered two recommendations to bypass the problem.
The way I fixed it is I forced the model to be related with the one that has the field I'm interested in order by.