--- a/autotweet-php/src/Org/W3/AutotweetBundle/Controller/DefaultController.php Wed Sep 04 11:31:39 2013 +0900
+++ b/autotweet-php/src/Org/W3/AutotweetBundle/Controller/DefaultController.php Wed Sep 04 11:39:17 2013 +0900
@@ -79,14 +79,24 @@
$key=$this->get('request')->request->get('accesskey');
$msg=$this->get('request')->request->get('note');
+ $hashtag=$this->get('request')->request->get('hashtag');
+ $auther=$this->get('request')->request->get('auther');
+ $title=$this->get('request')->request->get('title');
$talk = $this->getDoctrine()->getRepository('OrgW3AutotweetBundle:Talk')->findOneBy(array('accesskey'=>$key));
echo 'Talk:' . count($talk);
if(0!=count($talk)){
$post = $this->getDoctrine()->getRepository('OrgW3AutotweetBundle:Post')->findBy(array('talk' =>$talk, 'content'=>$msg));
+ if(null!=$auther){
+ $editparam = $this->getDoctrine()->getRepository('OrgW3AutotweetBundle:Talk')->updateAuther($talk, $auther);
+ }
+ if(null!=$title){
+ $editparam = $this->getDoctrine()->getRepository('OrgW3AutotweetBundle:Talk')->updateTitle($talk, $title);
+ }
echo 'Post:' . count($post);
if(0==count($post)){
$newpost = $this->getDoctrine()->getRepository('OrgW3AutotweetBundle:Post')->addnew($talk,$msg);
- $this->tweet($msg);
+ $msg_out=$this->splitPost($msg,140, $hashdag);
+ $this->tweet($msg_out);
}
}
@@ -127,7 +137,7 @@
//close connection
curl_close($ch);
}
- private function splitPost($name)
+ private function splitPost($post,$length, $hashdag=null)
{
//分割文字数を計算
//分割文字数=制限-フッタ文字数
@@ -152,5 +162,10 @@
//Try split /w write fullstop(JP).
//Try split /w write space.
//Try split /w write space.
+ if(null!=$hashtag){
+ return $post;
+ }else{
+ return $post . ' ' . $hashdag;
+ }
}
}
--- a/autotweet-php/src/Org/W3/AutotweetBundle/Entity/Talk.php Wed Sep 04 11:31:39 2013 +0900
+++ b/autotweet-php/src/Org/W3/AutotweetBundle/Entity/Talk.php Wed Sep 04 11:39:17 2013 +0900
@@ -36,6 +36,21 @@
/**
* @var string
*
+ * @ORM\Column(name="title", type="string", length=255, nullable=true)
+ */
+ private $title;
+
+
+ /**
+ * @var string
+ *
+ * @ORM\Column(name="auther", type="string", length=255, nullable=true)
+ */
+ private $auther;
+
+ /**
+ * @var string
+ *
* @ORM\Column(name="accesskey", type="string", length=255)
*/
private $accesskey;
@@ -194,4 +209,50 @@
{
return $this->accesskey;
}
+
+ /**
+ * Set title
+ *
+ * @param string $title
+ * @return Talk
+ */
+ public function setTitle($title)
+ {
+ $this->title = $title;
+
+ return $this;
+ }
+
+ /**
+ * Get title
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Set auther
+ *
+ * @param string $auther
+ * @return Talk
+ */
+ public function setAuther($auther)
+ {
+ $this->auther = $auther;
+
+ return $this;
+ }
+
+ /**
+ * Get auther
+ *
+ * @return string
+ */
+ public function getAuther()
+ {
+ return $this->auther;
+ }
}
\ No newline at end of file
--- a/autotweet-php/src/Org/W3/AutotweetBundle/Entity/TalkRepository.php Wed Sep 04 11:31:39 2013 +0900
+++ b/autotweet-php/src/Org/W3/AutotweetBundle/Entity/TalkRepository.php Wed Sep 04 11:39:17 2013 +0900
@@ -33,4 +33,25 @@
$em_default->flush();
return $post;
}
+
+ public function updateAuther($talk,$auther)
+ {
+ $em_default = $this->getEntityManager('default');
+
+
+ $post= $talk;
+ $post->setAuther($auther);
+ $em_default->flush();
+ return $post;
+ }
+ public function updateTitle($talk,$title)
+ {
+ $em_default = $this->getEntityManager('default');
+
+
+ $post= $talk;
+ $post->setTitle($title);
+ $em_default->flush();
+ return $post;
+ }
}